Macro syn::not [] [src]

macro_rules! not {
    ($i:expr, $submac:ident!( $($args:tt)* )) => { ... };
}

Invert the result of a parser by parsing successfully if the given parser fails to parse and vice versa.

Does not consume any of the input.

  • Syntax: not!(THING)
  • Output: ()
#[macro_use]
extern crate syn;

use syn::{Expr, Ident};

/// Parses any expression that does not begin with a `-` minus sign.
named!(not_negative_expr -> Expr, do_parse!(
    not!(punct!(-)) >>
    e: syn!(Expr) >>
    (e)
));

This macro is available if Syn is built with the "parsing" feature.