[−][src]Struct whasm::grammar::core::list::List
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,
T: Send,
impl<T> Sync for List<T> where
T: Sync,
T: Sync,
impl<T> Unpin for List<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for List<T> where
T: UnwindSafe,
T: UnwindSafe,
impl<T> RefUnwindSafe for List<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = !
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,