Expand description
This module contains free-standing functions for creating AST fragments out of smaller pieces.
Note that all functions here intended to be stupid constructors, which just
assemble a finish node from immediate children. If you want to do something
smarter than that, it belongs to the ext
submodule.
Keep in mind that from_text
functions should be kept private. The public
API should require to assemble every node piecewise. The trick of
parse(format!())
we use internally is an implementation detail – long
term, it will be replaced with quote!
. Do not add more usages to from_text
-
use quote!
instead.
Modules§
- ext
- While the parent module defines basic atomic “constructors”, the
ext
module defines shortcuts for common things. - tokens
Functions§
- arg_
list - assoc_
item_ list - async_
move_ block_ expr - attr_
inner - attr_
outer - block_
expr - const_
param - enum_
- expr_
assignment - expr_
await - expr_
bin_ op - expr_
break - expr_
call - expr_
closure - expr_
const_ value - expr_
continue - expr_
empty_ block - expr_
field - expr_
for_ loop - expr_if
- expr_
let - expr_
literal - expr_
loop - expr_
macro_ call - expr_
match - expr_
method_ call - expr_
paren - expr_
path - expr_
prefix - expr_
reborrow - expr_
ref - expr_
return - expr_
stmt - expr_
try - expr_
tuple - expr_
while_ loop - fn_
- generic_
arg_ list - generic_
param_ list - generic_
ty_ path_ segment - Type and expressions/patterns path differ in whether they require
::
before generic arguments. Type paths allow them but they are often omitted, while expression/pattern paths require them. - hacky_
block_ expr - Ideally this function wouldn’t exist since it involves manual indenting.
It differs from
make::block_expr
by also supporting comments and whitespace. - ident_
pat - impl_
- impl_
trait - impl_
trait_ type - item_
const - item_
static - join_
paths - let_
else_ stmt - let_
stmt - lifetime
- lifetime_
arg - lifetime_
param - literal_
pat - match_
arm - match_
arm_ list - match_
arm_ with_ guard - match_
guard - meta_
expr - meta_
path - meta_
token_ tree - mut_
self_ param - name
- name_
ref - or_pat
- Returns a
Pat
if the path has just one segment, anOrPat
otherwise. - param
- param_
list - path_
concat - path_
from_ segments - path_
from_ text - path_
from_ text_ with_ edition - path_
pat - Returns a
IdentPat
if the path has just one segment, aPathPat
otherwise. - path_
qualified - path_
segment - path_
segment_ crate - path_
segment_ self - path_
segment_ super - path_
segment_ ty - path_
unqualified - record_
expr - record_
expr_ field - record_
expr_ field_ list - record_
field - record_
field_ list - record_
pat - record_
pat_ field - record_
pat_ field_ list - record_
pat_ field_ shorthand - record_
pat_ with_ fields - rest_
pat - ret_
type - self_
param - slice_
pat - struct_
- tail_
only_ block_ expr - token
- token_
tree - trait_
- tuple_
field - tuple_
field_ list - tuple_
pat - Creates a tuple of patterns from an iterator of patterns.
- tuple_
struct_ pat - turbofish_
generic_ arg_ list - ty
- ty_
alias - ty_
fn_ ptr - ty_path
- ty_
placeholder - ty_ref
- ty_
tuple - ty_unit
- type_
arg - type_
bound - type_
bound_ list - type_
bound_ text - type_
param - unnamed_
param - use_
- use_
tree - use_
tree_ glob - use_
tree_ list - variant
- variant_
list - visibility_
pub - visibility_
pub_ crate - where_
clause - where_
pred - wildcard_
pat