Skip to main content

FixedBytesVecExt

Trait FixedBytesVecExt 

pub trait FixedBytesVecExt {
    // Required method
    fn into_flattened(self) -> Vec<u8> ;
}
Expand description

Extension trait for flattening a Vec of FixedBytes to a Vec<u8>.

This mirrors the standard library’s into_flattened method for Vec<[T; N]>.

Required Methods§

fn into_flattened(self) -> Vec<u8>

Takes a Vec<FixedBytes<N>> and flattens it into a Vec<u8>.

§Panics

This panics if the length of the resulting vector would overflow a usize.

This is only possible when N == 0, which tends to be irrelevant in practice.

§Examples
use alloy_primitives::{FixedBytes, FixedBytesVecExt};

let mut vec = vec![
    FixedBytes::<4>::new([1, 2, 3, 4]),
    FixedBytes::new([5, 6, 7, 8]),
    FixedBytes::new([9, 10, 11, 12]),
];
assert_eq!(vec.pop(), Some(FixedBytes::new([9, 10, 11, 12])));

let mut flattened = vec.into_flattened();
assert_eq!(flattened.pop(), Some(8));

Implementations on Foreign Types§

§

impl FixedBytesVecExt for Vec<Address>

§

fn into_flattened(self) -> Vec<u8>

§

impl FixedBytesVecExt for Vec<Bloom>

§

fn into_flattened(self) -> Vec<u8>

§

impl<const BITS: usize, const LIMBS: usize> FixedBytesVecExt for Vec<Uint<BITS, LIMBS>>

§

fn into_flattened(self) -> Vec<u8>

§

impl<const N: usize> FixedBytesVecExt for Vec<FixedBytes<N>>

§

fn into_flattened(self) -> Vec<u8>

Implementors§