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

    macro_rules! tag {
        ($i:expr, $tag:expr) => { ... };
    }

Parse the given string from exactly the current position in the input. You almost always want `punct!` or `keyword!` instead of this.

The `tag!` parser is equivalent to `punct!` but does not ignore leading whitespace. Both `punct!` and `keyword!` skip over leading whitespace. See an explanation of synom's whitespace handling strategy in the top-level crate documentation.

- Syntax: `tag!("...")`
- Output: `"..."`

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

    use syn::StrLit;
    use syn::parse::string;
    use synom::IResult;

    // Parse a proposed syntax for an owned string literal: "abc"s
    named!(owned_string -> String,
        map!(
            terminated!(string, tag!("s")),
            |lit: StrLit| lit.value
        )
    );

    fn main() {
        let input = r#"  "abc"s  "#;
        let parsed = owned_string(input).expect("owned string literal");
        println!("{:?}", parsed);

        let input = r#"  "abc" s  "#;
        let err = owned_string(input);
        assert_eq!(err, IResult::Error);
    }

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