String
These types are used to access the source of the syntax tree. For example, getting the name of a variable.
tp::Parse<S: FromStr, T>
is used for types that implementFromStr
, such as numeric types. It stores the parse result.tp::Quote<S: From<&str>, T>
on the other hand, stores the string value directly.tp::String
is an alias fortp::Quote<String, T>
.
Example
Ident
and Integer
are terminal structs not shown here.
Deref
tp::Parse
can be dereferenced to the parse Result
, and tp::Quote
can be dereferenced to the inner string value.
Parsing
The string types parse exactly the same as the inner syntax tree type T
. After parsing is successful,
the content is parsed/copied to the corresponding type.
If you want to avoid copying, you can use the inner type directly (which usually only stores a span), and use the span to access the source string when needed.