Macro scan

Source
macro_rules! scan {
    (@assert $p:pat) => { ... };
    (@assert $($p:tt)*) => { ... };
    (@pat $scanner:expr, [] []) => { ... };
    (@pat $scanner:expr, [] [] , $($t:tt)*) => { ... };
    (@pat $scanner:expr, [$($p:tt)*] [] $x:ident $($t:tt)*) => { ... };
    (@pat $scanner:expr, [$($p:tt)*] [] :: $($t:tt)*) => { ... };
    (@pat $scanner:expr, [$($p:tt)*] [] & $($t:tt)*) => { ... };
    (@pat $scanner:expr, [$($p:tt)*] [] ($($x:tt)*) $($t:tt)*) => { ... };
    (@pat $scanner:expr, [$($p:tt)*] [] [$($x:tt)*] $($t:tt)*) => { ... };
    (@pat $scanner:expr, [$($p:tt)*] [] {$($x:tt)*} $($t:tt)*) => { ... };
    (@pat $scanner:expr, [$($p:tt)*] [] : $($t:tt)*) => { ... };
    (@pat $scanner:expr, [$($p:tt)*] [] $($t:tt)*) => { ... };
    (@ty  $scanner:expr, [$($p:tt)*] [$($tt:tt)*] @$e:expr) => { ... };
    (@ty  $scanner:expr, [$($p:tt)*] [$($tt:tt)*] @$e:expr, $($t:tt)*) => { ... };
    (@ty  $scanner:expr, [$($p:tt)*] [$($tt:tt)*] ($($x:tt)*) $($t:tt)*) => { ... };
    (@ty  $scanner:expr, [$($p:tt)*] [$($tt:tt)*] [$($x:tt)*] $($t:tt)*) => { ... };
    (@ty  $scanner:expr, [$($p:tt)*] [$($tt:tt)*] $ty:ty) => { ... };
    (@ty  $scanner:expr, [$($p:tt)*] [$($tt:tt)*] $ty:ty, $($t:tt)*) => { ... };
    (@let $scanner:expr, [$($p:tt)*] [$($tt:tt)*] $($t:tt)*) => { ... };
    (src = $src:expr, $($t:tt)*) => { ... };
    ($scanner:expr, $($t:tt)*) => { ... };
}
Expand description

scan and bind values with Scanner

  • scan!(scanner, $($pat $(: ELEMENT)?),*)