Builder

Struct Builder 

Source
pub struct Builder { /* private fields */ }

Implementations§

Source§

impl Builder

Source

pub fn new() -> Builder

Source

pub fn vis<V: Make<Visibility>>(self, vis: V) -> Self

Source

pub fn pub_(self) -> Self

Source

pub fn set_mutbl<M: Make<Mutability>>(self, mutbl: M) -> Self

Source

pub fn mutbl(self) -> Self

Source

pub fn unsafety<U: Make<Unsafety>>(self, unsafety: U) -> Self

Source

pub fn unsafe_(self) -> Self

Source

pub fn constness<C: Make<Constness>>(self, constness: C) -> Self

Source

pub fn const_(self) -> Self

Source

pub fn extern_<A: Make<Extern>>(self, ext: A) -> Self

Source

pub fn span<S: Make<Span>>(self, span: S) -> Self

Source

pub fn generic_over(self, param: GenericParam) -> Self

Source

pub fn prepared_attr(self, meta: Meta) -> Self

Source

pub fn str_attr<K, V>(self, key: K, value: V) -> Self
where K: Make<Path>, V: Make<Lit>,

Source

pub fn single_attr<K>(self, key: K) -> Self
where K: Make<Path>,

Source

pub fn call_attr<K, V>(self, func: K, arguments: V) -> Self
where K: Make<Path>, V: Make<TokenStream>,

Source

pub fn path_segment_with_args<I, P>(self, identifier: I, args: P) -> PathSegment
where I: Make<Ident>, P: Make<PathArguments>,

Source

pub fn angle_bracketed_args<A>( self, args: Vec<A>, ) -> AngleBracketedGenericArguments

Source

pub fn generic_arg<A>(self, arg: A) -> GenericArgument

Source

pub fn ident<I>(self, name: I) -> Ident
where I: Make<Ident>,

Source

pub fn path_segment<S>(self, seg: S) -> PathSegment
where S: Make<PathSegment>,

Source

pub fn path<Pa>(self, path: Pa) -> Path
where Pa: Make<Path>,

Source

pub fn use_tree<Pa>(self, prefix: Pa, tree: UseTree) -> UseTree
where Pa: Make<Path>,

Source

pub fn abs_path<Pa>(self, path: Pa) -> Path
where Pa: Make<Path>,

Source

pub fn array_expr(self, args: Vec<Box<Expr>>) -> Box<Expr>

Source

pub fn call_expr(self, func: Box<Expr>, args: Vec<Box<Expr>>) -> Box<Expr>

Source

pub fn method_call_expr<S>( self, expr: Box<Expr>, seg: S, args: Vec<Box<Expr>>, ) -> Box<Expr>
where S: Make<PathSegment>,

Source

pub fn tuple_expr(self, exprs: Vec<Box<Expr>>) -> Box<Expr>

Source

pub fn binary_expr(self, op: BinOp, lhs: Box<Expr>, rhs: Box<Expr>) -> Box<Expr>

Source

pub fn unary_expr<O>(self, op: O, a: Box<Expr>) -> Box<Expr>
where O: Make<UnOp>,

Source

pub fn lit_expr<L>(self, lit: L) -> Box<Expr>
where L: Make<Lit>,

Source

pub fn cast_expr(self, e: Box<Expr>, t: Box<Type>) -> Box<Expr>

Source

pub fn unsafe_block_expr(self, unsafe_blk: ExprUnsafe) -> Box<Expr>

Source

pub fn block_expr(self, block: Block) -> Box<Expr>

Source

pub fn labelled_block_expr<L>(self, block: Block, lbl: L) -> Box<Expr>
where L: Make<Label>,

Source

pub fn assign_expr(self, lhs: Box<Expr>, rhs: Box<Expr>) -> Box<Expr>

Source

pub fn assign_op_expr( self, op: BinOp, lhs: Box<Expr>, rhs: Box<Expr>, ) -> Box<Expr>

Source

pub fn index_expr(self, lhs: Box<Expr>, rhs: Box<Expr>) -> Box<Expr>

Source

pub fn abs_path_expr<Pa>(self, path: Pa) -> Box<Expr>
where Pa: Make<Path>,

Source

pub fn path_expr<Pa>(self, path: Pa) -> Box<Expr>
where Pa: Make<Path>,

Source

pub fn qpath_expr<Pa>(self, qself: Option<QSelf>, path: Pa) -> Box<Expr>
where Pa: Make<Path>,

Source

pub fn repeat_expr(self, expr: Box<Expr>, n: Box<Expr>) -> Box<Expr>

An array literal constructed from one repeated element. [expr; n]

Source

pub fn paren_expr(self, e: Box<Expr>) -> Box<Expr>

Source

pub fn ident_expr<I>(self, name: I) -> Box<Expr>
where I: Make<Ident>,

Source

pub fn addr_of_expr(self, e: Box<Expr>) -> Box<Expr>

Source

pub fn mac_expr(self, mac: Macro) -> Box<Expr>

Source

pub fn struct_expr<Pa>(self, path: Pa, fields: Vec<FieldValue>) -> Box<Expr>
where Pa: Make<Path>,

Source

pub fn struct_expr_base<Pa>( self, path: Pa, fields: Vec<FieldValue>, base: Option<Box<Expr>>, ) -> Box<Expr>
where Pa: Make<Path>,

Source

pub fn field_expr<F>(self, val: Box<Expr>, field: F) -> Box<Expr>
where F: Make<Ident>,

Source

pub fn anon_field_expr(self, val: Box<Expr>, field: u32) -> Box<Expr>

Source

pub fn field<I>(self, ident: I, expr: Box<Expr>) -> FieldValue
where I: Make<Ident>,

Source

pub fn match_expr(self, cond: Box<Expr>, arms: Vec<Arm>) -> Box<Expr>

Source

pub fn arm(self, pat: Pat, guard: Option<Box<Expr>>, body: Box<Expr>) -> Arm

Source

pub fn int_lit(self, i: u128, ty: &str) -> Lit

Source

pub fn int_unsuffixed_lit<S>(self, s: S) -> Lit
where S: Make<String>,

Source

pub fn float_lit(self, s: &str, ty: &str) -> Lit

Source

pub fn float_unsuffixed_lit(self, s: &str) -> Lit

Source

pub fn bool_lit(self, b: bool) -> Lit

Source

pub fn str_lit(self, s: &str) -> Lit

Source

pub fn ifte_expr( self, cond: Box<Expr>, then_branch: Block, else_branch: Option<Box<Expr>>, ) -> Box<Expr>

Source

pub fn while_expr<I>( self, cond: Box<Expr>, body: Block, label: Option<I>, ) -> Box<Expr>
where I: Make<Ident>,

Source

pub fn loop_expr<I>(self, body: Block, label: Option<I>) -> Box<Expr>
where I: Make<Ident>,

Source

pub fn for_expr<I>( self, pat: Pat, expr: Box<Expr>, body: Block, label: Option<I>, ) -> Box<Expr>
where I: Make<Ident>,

Source

pub fn ident_pat<I>(self, name: I) -> Pat
where I: Make<Ident>,

Source

pub fn tuple_pat(self, pats: Vec<Pat>) -> Pat

Source

pub fn qpath_pat<Pa>(self, qself: Option<QSelf>, path: Pa) -> Box<Pat>
where Pa: Make<Path>,

Source

pub fn wild_pat(self) -> Pat

Source

pub fn lit_pat(self, lit: Lit) -> Pat

Source

pub fn path_pat(self, path: Path, qself: Option<QSelf>) -> Pat

Source

pub fn mac_pat(self, mac: Macro) -> Pat

Source

pub fn ident_ref_pat<I>(self, name: I) -> Pat
where I: Make<Ident>,

Source

pub fn or_pat(self, pats: Vec<Pat>) -> Pat

Source

pub fn barefn_ty( self, decl: (Vec<BareFnArg>, Option<BareVariadic>, ReturnType), ) -> Box<Type>

Source

pub fn array_ty(self, ty: Box<Type>, len: Box<Expr>) -> Box<Type>

Source

pub fn slice_ty(self, ty: Box<Type>) -> Box<Type>

Source

pub fn ptr_ty(self, ty: Box<Type>) -> Box<Type>

Source

pub fn ref_ty(self, ty: Box<Type>) -> Box<Type>

Source

pub fn ref_lt_ty<L>(self, lt: L, ty: Box<Type>) -> Box<Type>
where L: Make<Lifetime>,

Source

pub fn never_ty(self) -> Box<Type>

Source

pub fn tuple_ty(self, elem_tys: Vec<Box<Type>>) -> Box<Type>

Source

pub fn path_ty<Pa>(self, path: Pa) -> Box<Type>
where Pa: Make<Path>,

Source

pub fn qpath_ty<Pa>(self, qself: Option<QSelf>, path: Pa) -> Box<Type>
where Pa: Make<Path>,

Source

pub fn ident_ty<I>(self, name: I) -> Box<Type>
where I: Make<Ident>,

Source

pub fn infer_ty(self) -> Box<Type>

Source

pub fn mac_ty(self, mac: Macro) -> Box<Type>

Source

pub fn local_stmt(self, local: Box<Local>) -> Stmt

Source

pub fn expr_stmt(self, expr: Box<Expr>) -> Stmt

Source

pub fn semi_stmt(self, expr: Box<Expr>) -> Stmt

Source

pub fn item_stmt(self, item: Box<Item>) -> Stmt

Source

pub fn mac_stmt(self, mac: Macro) -> Stmt

Source

pub fn static_item<I>( self, name: I, ty: Box<Type>, init: Box<Expr>, ) -> Box<Item>
where I: Make<Ident>,

Source

pub fn const_item<I>(self, name: I, ty: Box<Type>, init: Box<Expr>) -> Box<Item>
where I: Make<Ident>,

Source

pub fn fn_item<S>(self, sig: S, block: Block) -> Box<Item>
where S: Make<Signature>,

Source

pub fn variadic_arg(self, name: Option<String>) -> Variadic

Source

pub fn bare_variadic_arg(self) -> BareVariadic

Source

pub fn fn_decl<I>( self, name: I, inputs: Vec<FnArg>, variadic: Option<Variadic>, output: ReturnType, ) -> Box<(Ident, Vec<FnArg>, Option<Variadic>, ReturnType)>
where I: Make<Ident>,

Source

pub fn struct_item<I>( self, name: I, fields: Vec<Field>, is_tuple: bool, ) -> Box<Item>
where I: Make<Ident>,

Source

pub fn union_item<I>(self, name: I, fields: Vec<Field>) -> Box<Item>
where I: Make<Ident>,

Source

pub fn enum_item<I>(self, name: I, fields: Vec<Variant>) -> Box<Item>
where I: Make<Ident>,

Source

pub fn type_item<I>(self, name: I, ty: Box<Type>) -> Box<Item>
where I: Make<Ident>,

Source

pub fn mod_item<I>(self, name: I, items: Option<Vec<Item>>) -> Box<Item>
where I: Make<Ident>,

Source

pub fn mod_(self, items: Vec<Box<Item>>) -> Vec<Item>

Source

pub fn mac_item(self, mac: Macro) -> Box<Item>

Source

pub fn variant<I>(self, name: I, fields: Fields) -> Variant
where I: Make<Ident>,

Source

pub fn unit_variant<I>(self, name: I, disc: Option<Box<Expr>>) -> Variant
where I: Make<Ident>,

Source

pub fn impl_item(self, ty: Box<Type>, items: Vec<ImplItem>) -> Box<Item>

Source

pub fn extern_crate_item<I>(self, name: I, rename: Option<I>) -> Box<Item>
where I: Make<Ident>,

Source

pub fn use_item(self, tree: UseTree) -> Box<Item>

Source

pub fn use_simple_item<Pa, I>(self, path: Pa, rename: Option<I>) -> Box<Item>
where Pa: Make<Path>, I: Make<Ident>,

Source

pub fn use_multiple_item<Pa, I, It>(self, path: Pa, inner: It) -> Box<Item>
where Pa: Make<Path>, I: Make<Ident>, It: Iterator<Item = I>,

Source

pub fn use_glob_item<Pa>(self, path: Pa) -> Box<Item>
where Pa: Make<Path>,

Source

pub fn foreign_items(self, items: Vec<ForeignItem>) -> Box<Item>

Source

pub fn get_abi(&self) -> Abi

Source

pub fn get_abi_opt(&self) -> Option<Abi>

Source

pub fn mac_impl_item(self, mac: Macro) -> ImplItem

Source

pub fn mac_trait_item(self, mac: Macro) -> TraitItem

Source

pub fn fn_foreign_item( self, decl: Box<(Ident, Vec<FnArg>, Option<Variadic>, ReturnType)>, ) -> Box<ForeignItem>

ForeignItem is large (472 bytes), so Box it.

Source

pub fn static_foreign_item<I>(self, name: I, ty: Box<Type>) -> Box<ForeignItem>
where I: Make<Ident>,

ForeignItem is large (472 bytes), so Box it.

Source

pub fn ty_foreign_item<I>(self, name: I) -> Box<ForeignItem>
where I: Make<Ident>,

ForeignItem is large (472 bytes), so Box it.

Source

pub fn mac_foreign_item(self, mac: Macro) -> ForeignItem

Source

pub fn struct_field<I>(self, ident: I, ty: Box<Type>) -> Field
where I: Make<Ident>,

Source

pub fn enum_field(self, ty: Box<Type>) -> Field

Source

pub fn unsafe_block(self, stmts: Vec<Stmt>) -> ExprUnsafe

Source

pub fn block(self, stmts: Vec<Stmt>) -> Block

Source

pub fn label<L>(self, lbl: L) -> Label
where L: Make<Label>,

Source

pub fn break_expr_value<L>( self, label: Option<L>, value: Option<Box<Expr>>, ) -> Box<Expr>
where L: Make<Label>,

Source

pub fn bare_arg<I>(self, ty: Box<Type>, name: Option<I>) -> BareFnArg
where I: Make<Box<Ident>>,

Source

pub fn arg(self, ty: Box<Type>, pat: Pat) -> FnArg

Source

pub fn self_arg(self, kind: SelfKind) -> FnArg

Source

pub fn ty_param<I>(self, ident: I) -> GenericParam
where I: Make<Ident>,

Source

pub fn ty<T>(self, kind: Type) -> Type

Source

pub fn lt_param<L>(self, lifetime: L) -> GenericParam
where L: Make<Lifetime>,

Source

pub fn lifetime<L: Make<Lifetime>>(self, lt: L) -> Lifetime

Source

pub fn attribute(self, style: AttrStyle, meta: Meta) -> Attribute

Source

pub fn meta_path<Pa>(self, path: Pa) -> Meta
where Pa: Make<Path>,

makes a meta item with just a path

§Examples

mk().meta_path(“C”) // -> C

Source

pub fn meta_list<I, N>(self, path: I, args: N) -> Meta
where I: Make<Path>, N: Make<TokenStream>,

makes a meta item with the given path and some arguments

§Examples

mk().meta_list(“derive”, vec![“Clone”, “Copy”]) // -> derive(Clone, Copy)

Source

pub fn meta_namevalue<K, V>(self, key: K, value: V) -> Meta
where K: Make<Path>, V: Make<Lit>,

makes a meta item with key value argument

§Examples

mk().meta_namevalue(“target_os”, “linux”) // -> target_os = "linux"

Source

pub fn empty_mac<Pa>(self, path: Pa, delim: MacroDelimiter) -> Macro
where Pa: Make<Path>,

Source

pub fn mac<Ts>(self, func: Path, arguments: Ts, delim: MacroDelimiter) -> Macro
where Ts: Make<TokenStream>,

Source

pub fn local( self, pat: Pat, ty: Option<Box<Type>>, init: Option<Box<Expr>>, ) -> Local

Create a local variable

Source

pub fn return_expr(self, val: Option<Box<Expr>>) -> Box<Expr>

Source

pub fn continue_expr<I>(self, label: Option<I>) -> Box<Expr>
where I: Make<Ident>,

Source

pub fn break_expr<I>(self, label: Option<I>) -> Box<Expr>
where I: Make<Ident>,

Source

pub fn closure_expr( self, capture: CaptureBy, mov: Movability, decl: (Ident, Vec<FnArg>, Option<Variadic>, ReturnType), body: Box<Expr>, ) -> Box<Expr>

Trait Implementations§

Source§

impl Clone for Builder

Source§

fn clone(&self) -> Builder

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Builder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Builder

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Make<T> for T

Source§

fn make(self, _mk: &Builder) -> T

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.