[−][src]Macro glsp::quote
quote!() { /* proc-macro */ }
Equivalent to '
.
The input must be a string literal which parses into a single value. The macro emits Rust code
which constructs that value, deep‑freezes it, and
returns it. For example, quote!("(a 1)")
will allocate a new array by calling:
arr![glsp::sym("a"), 1]
The first time that each quote!()
is evaluated, the result is cached in the active
Runtime
. Any subsequent evaluations in that same
Runtime
will return the cached value, without performing
any new allocations.
The result has a generic return type - it can be any type which implements
FromVal
. It should be bound to a local variable with a concrete type.
let arr: Root<Arr> = quote!("(a b c)"); let i: i64 = quote!("100"); let val: Val = quote!("#((key0 #t) (key1 #f))");
In the unlikely event that conversion from Val
to the destination type fails,
a panic will occur.
Unquoting (~
) is not supported. If you need to interpolate local variables, use
backquote!()
instead.