8 releases (5 breaking)

0.6.1 Sep 2, 2023
0.6.0 Aug 29, 2023
0.5.0 Aug 23, 2023
0.4.0 Aug 20, 2023
0.1.0 May 7, 2023

#1386 in Procedural macros

Download history 62/week @ 2023-05-22 119/week @ 2023-05-29 87/week @ 2023-06-05 67/week @ 2023-06-12 136/week @ 2023-06-19 12/week @ 2023-06-26 37/week @ 2023-07-03 16/week @ 2023-07-10 15/week @ 2023-07-17 103/week @ 2023-07-24 128/week @ 2023-07-31 97/week @ 2023-08-07 111/week @ 2023-08-14 256/week @ 2023-08-21 383/week @ 2023-08-28 216/week @ 2023-09-04

968 downloads per month
Used in 11 crates (via devela)

MIT/Apache

19KB
239 lines

devela_macros

Crate API MSRV: 1.60.0

Procedural macros for devela.

See the documentation for more information.

Status

This is currently in an experimental stage of development.

License

This project is dual licensed under either MIT or Apache-2.0 at your option.

Contributing

Contributions are welcomed to help refine and improve this library over time. If you notice a bug, have an idea for a new feature, or simply want to suggest improvements to the existing codebase, please get in touch.


lib.rs:

Conditional compilation

Each form of conditional compilation takes a compilation predicate that evaluates to true or false.

These are the [#[compile]][compile()] and [#[compile_attr]][compile_attr()] attributes and the [cif!][cif()] macro.

They are similar to the #[cfg] and #[cfg_attr] attributes and the cfg! macro, except they use compilation predicates.

Compilation predicates

The following compilation predicates are supported:

  • unary:

    • A bare predicate returns true only if it is the true literal
    • not(): returns true only if the predicate does not evaluate to true.
  • binary:

    • eq(): returns true if both predicates are evaluated as equal.
    • ne(): returns true if both predicates are not evaluated as equal.
    • xor(): returns true if only one predicate is true, but not both.
    • ge(): returns true if both predicates are numbers and the first >= the second.
    • gt(): returns true if both predicates are numbers and the first > the second.
    • le(): returns true if both predicates are numbers and the first <= the second.
    • lt(): returns true if both predicates are numbers and the first < the second.
  • non-binary:

    • any(): returns true if any predicate is true.
    • all(): returns true if all predicates are true.
    • none(): returns true if there is no given predicate.
    • some(): returns true if there is some given predicate.
    • diff(): returns true if any predicate has a different text.
    • same(): returns true if all the predicates have the same text.
    • xany(): returns true if there are any true predicates, but not all.
    • xodd(): returns true if there is an odd number of true predicates.
    • xone(): returns true if there is just one true predicate, but no more.

When more than 1 predicate is supported, they are separated by commas.

No runtime deps

Features