Expand description
Defines a function.
Fields
body: Option<Vec<Body>>
Body contents
Implementations
sourceimpl 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 arg<T>(&mut self, name: &str, ty: T) -> &mut Selfwhere
T: Into<Type>,
pub fn arg<T>(&mut self, name: &str, ty: T) -> &mut Selfwhere
T: Into<Type>,
Add a function argument.
sourcepub fn bound<T>(&mut self, name: &str, ty: T) -> &mut Selfwhere
T: Into<Type>,
pub fn bound<T>(&mut self, name: &str, ty: T) -> &mut Selfwhere
T: Into<Type>,
Add a where
bound to the function.
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::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::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 RefUnwindSafe for Function
impl Send for Function
impl Sync for Function
impl Unpin for Function
impl UnwindSafe for Function
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more