Trait byte_slice_cast::IntoByteVec[][src]

pub trait IntoByteVec {
    fn into_byte_vec(self) -> Vec<u8>;
}

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

Example

use byte_slice_cast::*;

let mut vec: Vec<u16> = vec![0x0102, 0x0304, 0x0506];
let converted_vec = vec.into_byte_vec();

if cfg!(target_endian = "big") {
    assert_eq!(converted_vec, vec![1u8, 2u8, 3u8, 4u8, 5u8, 6u8]);
} else {
    assert_eq!(converted_vec, vec![2u8, 1u8, 4u8, 3u8, 6u8, 5u8]);
}

Required methods

fn into_byte_vec(self) -> Vec<u8>[src]

Loading content...

Implementations on Foreign Types

impl IntoByteVec for Vec<u8>[src]

impl IntoByteVec for Vec<u16>[src]

impl IntoByteVec for Vec<u32>[src]

impl IntoByteVec for Vec<u64>[src]

impl IntoByteVec for Vec<u128>[src]

impl IntoByteVec for Vec<i8>[src]

impl IntoByteVec for Vec<i16>[src]

impl IntoByteVec for Vec<i32>[src]

impl IntoByteVec for Vec<i64>[src]

impl IntoByteVec for Vec<i128>[src]

impl IntoByteVec for Vec<f32>[src]

impl IntoByteVec for Vec<f64>[src]

impl IntoByteVec for Vec<usize>[src]

impl IntoByteVec for Vec<isize>[src]

Loading content...

Implementors

Loading content...