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§
- While the parent module defines basic atomic “constructors”, the
ext
module defines shortcuts for common things.
Functions§
- 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. - Ideally this function wouldn’t exist since it involves manual indenting. It differs from
make::block_expr
by also supporting comments and whitespace. - Returns a
Pat
if the path has just one segment, anOrPat
otherwise. - Returns a
BindPat
if the path has just one segment, aPathPat
otherwise. - Creates a tuple of patterns from an iterator of patterns.