Macro nxml_ref

Source
nxml_ref!() { /* proc-macro */ }
Expand description

Creates an ElementRef from an XML-like syntax.

§Examples

With no expressions, the result is ElementRef<'static>:

assert_static(nxml_ref!(<Entity prop="static" />));

The lifetime is narrowed down to the shortest one of given expressions:

let prop = String::from("value");

let element = nxml_ref!(<Entity {&prop} />); // borrowed value does not live long enough..

assert_static(element); // ..argument requires that `prop` is borrowed for `'static`

And, unlike nxml!, the expressions must be &str:

let prop = 42;
nxml_ref!(<Entity {prop} />); // expected `&str`, found integer