FunctionDefinition
std::meta::function_def
contains methods on the built-in FunctionDefinition
type representing
a function definition in the source program.
Methods
name
fn name(self) -> Quoted {}
Returns the name of the function.
parameters
fn parameters(self) -> [(Quoted, Type)] {}
Returns each parameter of the function as a tuple of (parameter pattern, parameter type).
return_type
fn return_type(self) -> Type {}
The return type of the function.
set_body
fn set_body(self, body: Quoted) {}
Mutate the function body to a new expression. This is only valid on functions in the current crate which have not yet been resolved. This means any functions called at compile-time are invalid targets for this method.
Requires the new body to be a valid expression.
set_parameters
fn set_parameters(self, parameters: [(Quoted, Type)]) {}
Mutates the function's parameters to a new set of parameters. This is only valid on functions in the current crate which have not yet been resolved. This means any functions called at compile-time are invalid targets for this method.
Expects a slice of (parameter pattern, parameter type) for each parameter. Requires each parameter pattern to be a syntactically valid parameter.
set_return_type
fn set_return_type(self, return_type: Type) {}
Mutates the function's return type to a new type. This is only valid on functions in the current crate which have not yet been resolved. This means any functions called at compile-time are invalid targets for this method.