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> ⓘ
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));