# Macro synom::alt [−] [src]

    macro_rules! alt {
        ($i:expr, $e:ident | $($rest:tt)*) => { ... };
        ($i:expr, $subrule:ident!( $($args:tt)*) | $($rest:tt)*) => { ... };
        ($i:expr, $subrule:ident!( $($args:tt)* ) => { $gen:expr } | $($rest:tt)+) => { ... };
        ($i:expr, $e:ident => { $gen:expr } | $($rest:tt)*) => { ... };
        ($i:expr, $e:ident => { $gen:expr }) => { ... };
        ($i:expr, $subrule:ident!( $($args:tt)* ) => { $gen:expr }) => { ... };
        ($i:expr, $e:ident) => { ... };
        ($i:expr, $subrule:ident!( $($args:tt)*)) => { ... };
    }

Run a series of parsers, returning the result of the first one which succeeds.

Optionally allows for the result to be transformed.

- Syntax: `alt!(THING1 | THING2 => { FUNC } | ...)`
- Output: `T`, the return type of `THING1` and `FUNC(THING2)` and ...

    extern crate syn;
    #[macro_use] extern crate synom;

    use syn::Ident;
    use syn::parse::ident;

    named!(ident_or_bang -> Ident,
        alt!(
            ident
            |
            punct!("!") => { |_| "BANG".into() }
        )
    );

    fn main() {
        let input = "foo";
        let parsed = ident_or_bang(input).expect("identifier or `!`");
        assert_eq!(parsed, "foo");

        let input = "!";
        let parsed = ident_or_bang(input).expect("identifier or `!`");
        assert_eq!(parsed, "BANG");
    }

# Help

## Keyboard Shortcuts

`?`
  Show this help dialog
`S`
  Focus the search field
`↑`
  Move up in search results
`↓`
  Move down in search results
`↹`
  Switch tab
`⏎`
  Go to active search result
`+`
  Expand all sections
`-`
  Collapse all sections

## Search Tricks

Prefix searches with a type followed by a colon (e.g. `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct`, `enum`, `trait`, `type`, `macro`, and `const`.

Search functions by type signature (e.g. `vec -> usize` or `* -> vec`)