pub struct Label { /* private fields */ }Expand description
A position in a function’s code, named before it is known.
Make one with FunctionBuilder::label, use it in branches, tables,
handlers, and local ranges, and bind it to the
next instruction’s position exactly once. A label belongs to the builder
that made it.
§Examples
use bytecode_lang::{Inst, ModuleBuilder, Target};
let mut m = ModuleBuilder::new();
let mut f = m.function("f", &[], &[]);
let end = f.label();
f.jmp(end);
f.emit(Inst::Nop {});
f.bind(end);
f.ret_void();
let id = m.add_function(f).unwrap();
let module = m.finish().unwrap();
assert_eq!(module.function(id).unwrap().code()[0], Inst::Jmp { target: Target(2) });Trait Implementations§
impl Copy for Label
impl Eq for Label
Source§impl Ord for Label
impl Ord for Label
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
Source§impl PartialOrd for Label
impl PartialOrd for Label
impl StructuralPartialEq for Label
Auto Trait Implementations§
impl Freeze for Label
impl RefUnwindSafe for Label
impl Send for Label
impl Sync for Label
impl Unpin for Label
impl UnsafeUnpin for Label
impl UnwindSafe for Label
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