Struct binary_util::Function
source · pub struct Function { /* private fields */ }
Expand description
Defines a function.
Implementations§
source§impl Function
impl Function
sourcepub fn allow(&mut self, allow: &str) -> &mut Function
pub fn allow(&mut self, allow: &str) -> &mut Function
Specify lint attribute to supress a warning or error.
sourcepub fn set_async(&mut self, async: bool) -> &mut Function
pub fn set_async(&mut self, async: bool) -> &mut Function
Set whether this function is async or not
sourcepub fn arg_ref_self(&mut self) -> &mut Function
pub fn arg_ref_self(&mut self) -> &mut Function
Add &self
as a function argument.
sourcepub fn arg_mut_self(&mut self) -> &mut Function
pub fn arg_mut_self(&mut self) -> &mut Function
Add &mut self
as a function argument.
sourcepub fn arg<T>(&mut self, name: &str, ty: T) -> &mut Functionwhere
T: Into<Type>,
pub fn arg<T>(&mut self, name: &str, ty: T) -> &mut Functionwhere T: Into<Type>,
Add a function argument.
sourcepub fn ret<T>(&mut self, ty: T) -> &mut Functionwhere
T: Into<Type>,
pub fn ret<T>(&mut self, ty: T) -> &mut Functionwhere T: Into<Type>,
Set the function return type.
sourcepub fn bound<T>(&mut self, name: &str, ty: T) -> &mut Functionwhere
T: Into<Type>,
pub fn bound<T>(&mut self, name: &str, ty: T) -> &mut Functionwhere T: Into<Type>,
Add a where
bound to the function.
sourcepub fn line<T>(&mut self, line: T) -> &mut Functionwhere
T: ToString,
pub fn line<T>(&mut self, line: T) -> &mut Functionwhere T: ToString,
Push a line to the function implementation.
sourcepub fn attr(&mut self, attribute: &str) -> &mut Function
pub fn attr(&mut self, attribute: &str) -> &mut Function
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 Function
pub fn extern_abi(&mut self, abi: &str) -> &mut Function
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 Function
pub fn push_block(&mut self, block: Block) -> &mut Function
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§
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