Struct wasmparser::BrTable[][src]

pub struct BrTable<'a> { /* fields omitted */ }
Expand description

A br_table entries representation.

Implementations

impl<'a> BrTable<'a>[src]

pub fn len(&self) -> usize[src]

Returns the number of br_table entries, not including the default label

pub fn is_empty(&self) -> bool[src]

Returns whether BrTable doesn’t have any labels apart from the default one.

pub fn targets<'b>(&'b self) -> impl Iterator<Item = Result<(u32, bool)>> + 'b[src]

Returns the list of targets that this br_table instruction will be jumping to.

This method will return an iterator which parses each target of this br_table as well as the default target. The returned iterator will yield self.len() + 1 elements.

Each iterator item is a tuple of (u32, bool), where the first item is the relative depth of the jump and the second item is true if the item is the default label. You’re guaranteed that true will only show up for the final element of the iterator.

#Examples

let buf = [0x0e, 0x02, 0x01, 0x02, 0x00];
let mut reader = wasmparser::BinaryReader::new(&buf);
let op = reader.read_operator().unwrap();
if let wasmparser::Operator::BrTable { table } = op {
    let targets = table.targets().collect::<Result<Vec<_>, _>>().unwrap();
    assert_eq!(targets, [(1, false), (2, false), (0, true)]);
}

Trait Implementations

impl<'a> Clone for BrTable<'a>[src]

fn clone(&self) -> BrTable<'a>[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Debug for BrTable<'_>[src]

fn fmt(&self, f: &mut Formatter<'_>) -> Result[src]

Formats the value using the given formatter. Read more

Auto Trait Implementations

impl<'a> RefUnwindSafe for BrTable<'a>

impl<'a> Send for BrTable<'a>

impl<'a> Sync for BrTable<'a>

impl<'a> Unpin for BrTable<'a>

impl<'a> UnwindSafe for BrTable<'a>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

Creates owned data from borrowed data, usually by cloning. Read more

pub fn clone_into(&self, target: &mut T)[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.