pub struct Function {
pub body: Option<Vec<Body>>,
/* private fields */
}
Expand description
Defines a function.
Fields§
§body: Option<Vec<Body>>
Body contents.
Implementations§
Source§impl Function
impl Function
Sourcepub fn arg_self(&mut self) -> &mut Self
pub fn arg_self(&mut self) -> &mut Self
Add self
as a function argument.
§Examples
use rust_codegen::Function;
let mut foo_fn = Function::new("foo_fn");
foo_fn.arg_self();
Sourcepub fn arg_ref_self(&mut self) -> &mut Self
pub fn arg_ref_self(&mut self) -> &mut Self
Add &self
as a function argument.
§Examples
use rust_codegen::Function;
let mut foo_fn = Function::new("foo_fn");
foo_fn.arg_ref_self();
Sourcepub fn arg_mut_self(&mut self) -> &mut Self
pub fn arg_mut_self(&mut self) -> &mut Self
Add &mut self
as a function argument.
§Examples
use rust_codegen::Function;
let mut foo_fn = Function::new("foo_fn");
foo_fn.arg_mut_self();
Sourcepub fn extern_abi(&mut self, abi: &str) -> &mut Self
pub fn extern_abi(&mut self, abi: &str) -> &mut Self
Sourcepub fn push_block(&mut self, block: Block) -> &mut Self
pub fn push_block(&mut self, block: Block) -> &mut Self
Sourcepub fn fmt(&self, is_trait: bool, fmt: &mut Formatter<'_>) -> Result
pub fn fmt(&self, is_trait: bool, fmt: &mut Formatter<'_>) -> Result
Formats the function using the given formatter.
§Arguments
is_trait
- Indicates whether it is a trait or not.fmt
- The formatter to use.
§Examples
use rust_codegen::*;
let mut dest = String::new();
let mut fmt = Formatter::new(&mut dest);
let mut foo_fn = Function::new("foo_fn");
foo_fn.fmt(false, &mut fmt);
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Function
impl RefUnwindSafe for Function
impl Send for Function
impl Sync for Function
impl Unpin for Function
impl UnwindSafe for Function
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more