Expand description
A number of helper functions meant to be used in the procedural enso-shapely-macros definitions.
Structs§
- Type
Gatherer - Visitor that accumulates all visited
syn::TypePath
.
Functions§
- field_
ident_ token - Returns token that refers to the field.
- field_
names - Returns names of the named fields.
- fields_
list - Collects all fields, named or not.
- gather_
all_ type_ reprs - All text representations of
TypePath
s in the given’sType
subtree. - gather_
all_ types - All
TypePath
s in the given’sType
subtree. - identifier_
sequence - For given length returns sequence of identifiers like
[field0,field1,…]
. - index_
sequence - For given length, returns a sequence of Literals like
[0,1,2…]
. These are unsuffixed usize literals, so e.g. can be used to identify the tuple unnamed fields. - last_
type_ arg - Last type argument of the last segment on the type path.
- map_
tokens - Maps all the tokens in the stream using a given function.
- matching_
ident - Is the given token an identifier matching to a given string?
- new_
where_ clause - Creates a new where clause from provided sequence of where predicates.
- path_
matching_ ident - Checks if a given
Path
consists of a single identifier same as given string. - path_
segment_ generic_ args - Obtain list of generic arguments on the path’s segment.
- repr
- Obtains text representation of given
ToTokens
-compatible input. - rewrite_
stream - Rewrites stream replacing each token with a sequence of tokens returned by the given function. The groups (e.g. token tree within braces) are unpacked, rewritten and repacked into groups – the function is applied recursively.
- ty_
path_ generic_ args - Obtain list of generic arguments on the path’s last segment.
- ty_
path_ type_ args - Obtain list of type arguments on the path’s last segment.
- type_
depends_ on - Does type depends on the given type parameter.
- type_
matches - Naive type equality test by comparing their text representations.
- type_
matches_ repr - Naive type equality test by comparing its representation with a string.
- variant_
depends_ on - Does enum variant depend on the given type parameter.