Module make

Source
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, an OrPat 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, a PathPat 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