nom_parse_macros

Attribute Macro parse_match

Source
#[parse_match]
Expand description

The parse_match macro can be used to match strings verbatim. This is useful when you have a very simple format that you want to parse. The {} gets replaced with a parser for the corresponding field. The rest of the characters are matched verbatim.

ยงExample

This example shows how to parse a three-dimensional vector from a string with a fixed format. As you can see, this macro is limited in its use, but is very straightforward to use in cases where it works.

use nom_parse_macros::parse_match;

#[parse_match("({},{},{})")]
struct Vector3 {
    x: u32,
    y: u32,
    z: u32,
}