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 allow(&mut self, allow: &str) -> &mut Self
pub fn allow(&mut self, allow: &str) -> &mut Self
Specify lint attribute to supress a warning or error.
Sourcepub fn set_async(&mut self, async: bool) -> &mut Self
pub fn set_async(&mut self, async: bool) -> &mut Self
Set whether this function is async or not
Sourcepub fn arg_ref_self(&mut self) -> &mut Self
pub fn arg_ref_self(&mut self) -> &mut Self
Add &self
as a function argument.
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.
Sourcepub fn line<T>(&mut self, line: T) -> &mut Selfwhere
T: ToString,
pub fn line<T>(&mut self, line: T) -> &mut Selfwhere
T: ToString,
Push a line to the function implementation.
Sourcepub fn attr(&mut self, attribute: &str) -> &mut Self
pub fn attr(&mut self, attribute: &str) -> &mut Self
Add an attribute to the function.
use codegen_rs::Function;
let mut func = Function::new("test");
// add a `#[test]` attribute
func.attr("test");
Sourcepub fn extern_abi(&mut self, abi: &str) -> &mut Self
pub fn extern_abi(&mut self, abi: &str) -> &mut Self
Specify an extern
ABI for the function.
use codegen_rs::Function;
let mut extern_func = Function::new("extern_func");
// use the "C" calling convention
extern_func.extern_abi("C");
Sourcepub fn push_block(&mut self, block: Block) -> &mut Self
pub fn push_block(&mut self, block: Block) -> &mut Self
Push a block to the function implementation
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