Enum syn_helpers::TraitItem
source · pub enum TraitItem {
Method {
name: Ident,
generic_parameters: Option<Vec<GenericParam>>,
self_type: TypeOfSelf,
other_parameters: Vec<FnArg>,
return_type: Option<Type>,
handler: Box<dyn for<'a> Fn(Item<'a>) -> Result<Vec<Stmt>, Box<dyn Error>>>,
},
AssociatedFunction {
name: Ident,
generic_parameters: Option<Vec<GenericParam>>,
parameters: Vec<FnArg>,
return_type: Option<Type>,
handler: Box<dyn for<'a> Fn(&'a mut Structure) -> Result<Vec<Stmt>, Box<dyn Error>>>,
},
}
Expand description
A item under a trait
Variants§
Method
AssociatedFunction
Implementations§
source§impl TraitItem
impl TraitItem
sourcepub fn new_method(
name: Ident,
generic_parameters: Option<Vec<GenericParam>>,
self_type: TypeOfSelf,
other_parameters: Vec<FnArg>,
return_type: Option<Type>,
handler: impl for<'a> Fn(Item<'a>) -> Result<Vec<Stmt>, Box<dyn Error>> + 'static
) -> Self
pub fn new_method(
name: Ident,
generic_parameters: Option<Vec<GenericParam>>,
self_type: TypeOfSelf,
other_parameters: Vec<FnArg>,
return_type: Option<Type>,
handler: impl for<'a> Fn(Item<'a>) -> Result<Vec<Stmt>, Box<dyn Error>> + 'static
) -> Self
Create a new method (something that takes self
, &self
or &mut self
)
sourcepub fn new_associated_function(
name: Ident,
generic_parameters: Option<Vec<GenericParam>>,
parameters: Vec<FnArg>,
return_type: Option<Type>,
handler: impl for<'a> Fn(&'a mut Structure) -> Result<Vec<Stmt>, Box<dyn Error>> + 'static
) -> Self
pub fn new_associated_function(
name: Ident,
generic_parameters: Option<Vec<GenericParam>>,
parameters: Vec<FnArg>,
return_type: Option<Type>,
handler: impl for<'a> Fn(&'a mut Structure) -> Result<Vec<Stmt>, Box<dyn Error>> + 'static
) -> Self
Create a new associated function (doesn’t take any reference of self)