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

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

Transform the result of a parser by applying a function or closure.

- Syntax: `map!(THING, FN)`
- Output: the return type of function FN applied to THING

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

    use syn::{Item, Ident};
    use syn::parse::item;

    fn get_item_ident(item: Item) -> Ident {
        item.ident
    }

    // Parses an item and returns the name (identifier) of the item only.
    named!(item_ident -> Ident,
        map!(item, get_item_ident)
    );

    // Or equivalently:
    named!(item_ident2 -> Ident,
        map!(item, |i: Item| i.ident)
    );

    fn main() {
        let input = "fn foo() {}";

        let parsed = item_ident(input).expect("item");

        assert_eq!(parsed, "foo");
    }

# 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`)