[][src]Struct whasm::grammar::core::list::List

pub struct List<T: Grammar>(pub Vec<T>);

A List<T> is a wrapper for a Vec<T>. It differs from a Vec<T> on how it is deserialized. The serialization of a Vec<T> begins with the number of elements N in the vector followed by each of the N elements. The serialization of a List<T> starts with the first element and continues reading until the iterator is exhausted.

After deserializing the last element of List<T>, the iterator must be exhausted. If not, the List<T> will try to deserialize a new T and append it to the list.

Example

let mut iter = [0x01, 0x02, 0x03, 0x04].iter().copied();
let List(result): List<Byte> = deserialize(&mut iter).unwrap();
assert_eq!(result, vec![0x01, 0x02, 0x03, 0x04]);
assert_eq!(iter.next(), None);

Deserialization will return an error if the iterator is not exhausted.

let mut iter = [0x00, 0x00, 0x00, 0x00, 0x05, 0x06].iter().copied();
let result: Result<List<f32>> = deserialize(&mut iter);
assert!(result.is_err());

Trait Implementations

impl<T: Grammar> Grammar for List<T>[src]

impl<T: PartialEq + Grammar> PartialEq<List<T>> for List<T>[src]

impl<T: Debug + Grammar> Debug for List<T>[src]

impl<T: Grammar> StructuralPartialEq for List<T>[src]

Auto Trait Implementations

impl<T> Send for List<T> where
    T: Send

impl<T> Sync for List<T> where
    T: Sync

impl<T> Unpin for List<T> where
    T: Unpin

impl<T> UnwindSafe for List<T> where
    T: UnwindSafe

impl<T> RefUnwindSafe for List<T> where
    T: RefUnwindSafe

Blanket Implementations

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

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

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

type Error = !

The type returned in the event of a conversion error.

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.

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

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

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