[][src]Trait byte_slice_cast::IntoVecOf

pub trait IntoVecOf {
    fn into_vec_of<T: FromByteVec>(self) -> Result<Vec<T>, Error>;
}

Trait for converting from a byte Vec<u8> to a Vec<T> of a fundamental, built-in numeric type.

Example

use byte_slice_cast::*;

let mut vec: Vec<u8> = vec![1u8, 2u8, 3u8, 4u8, 5u8, 6u8];
let converted_vec = vec.into_vec_of::<u16>().unwrap();

if cfg!(target_endian = "big") {
    assert_eq!(converted_vec, vec![0x0102, 0x0304, 0x0506]);
} else {
    assert_eq!(converted_vec, vec![0x0201, 0x0403, 0x0605]);
}

Required methods

fn into_vec_of<T: FromByteVec>(self) -> Result<Vec<T>, Error>

Loading content...

Implementations on Foreign Types

impl IntoVecOf for Vec<u8>[src]

Loading content...

Implementors

Loading content...