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

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

Turn a failed parse into an empty vector. The argument parser must itself return a vector.

This is often more convenient than `option!(...)` when the argument produces a vector.

- Syntax: `opt_vec!(THING)`
- Output: `THING`, which must be `Vec<T>`

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

    use syn::{Lifetime, Ty};
    use syn::parse::{lifetime, ty};

    named!(bound_lifetimes -> (Vec<Lifetime>, Ty), tuple!(
        opt_vec!(do_parse!(
            keyword!("for") >>
            punct!("<") >>
            lifetimes: terminated_list!(punct!(","), lifetime) >>
            punct!(">") >>
            (lifetimes)
        )),
        ty
    ));

    fn main() {
        let input = "for<'a, 'b> fn(&'a A) -> &'b B";
        let parsed = bound_lifetimes(input).expect("bound lifetimes");
        assert_eq!(parsed.0, [Lifetime::new("'a"), Lifetime::new("'b")]);
        println!("{:?}", parsed);

        let input = "From<String>";
        let parsed = bound_lifetimes(input).expect("bound lifetimes");
        assert!(parsed.0.is_empty());
        println!("{:?}", parsed);
    }

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