Macro wast::custom_keyword 
source · [−]macro_rules! custom_keyword {
    ($name:ident) => { ... };
    ($name:ident = $kw:expr) => { ... };
}Expand description
A macro to create a custom keyword parser.
This macro is invoked in one of two forms:
// keyword derived from the Rust identifier:
wast::custom_keyword!(foo);
// or an explicitly specified string representation of the keyword:
wast::custom_keyword!(my_keyword = "the-wasm-keyword");This can then be used to parse custom keyword for custom items, such as:
use wast::parser::{Parser, Result, Parse};
struct InlineModule<'a> {
    inline_text: &'a str,
}
mod kw {
    wast::custom_keyword!(inline);
}
// Parse an inline string module of the form:
//
//    (inline "(module (func))")
impl<'a> Parse<'a> for InlineModule<'a> {
    fn parse(parser: Parser<'a>) -> Result<Self> {
        parser.parse::<kw::inline>()?;
        Ok(InlineModule {
            inline_text: parser.parse()?,
        })
    }
}Note that the keyword name can only start with a lower-case letter, i.e. ‘a’..‘z’.