devela::all

Macro capture_first

Source
macro_rules! capture_first {
    (block $first:block $(, $tail:block)* $(,)?) => { ... };
    (expr $first:expr $(, $tail:expr)* $(,)?) => { ... };
    (ident $first:ident $(, $tail:ident)* $(,)?) => { ... };
    (literal $first:literal $(, $tail:literal)* $(,)?) => { ... };
    (meta $first:meta $(, $tail:meta)* $(,)?) => { ... };
    (pat $first:pat $(, $tail:pat)* $(,)?) => { ... };
    (path $first:path $(, $tail:path)* $(,)?) => { ... };
    (ty $first:ty $(, $tail:ty)* $(,)?) => { ... };
    (tt $first:tt $(, $tail:tt)* $(,)?) => { ... };
}
Expand description

Captures the first token from a list of inputs.

Usage: first!(<category> <first>, <tail>*, <optional_comma>?);

ยงExample

assert_eq![5, capture_first!(expr 5, 6, 7)];
assert_eq![42, capture_first!(literal 42, "hello", true)];