Macro array_bytes::dyn_into [−][src]
macro_rules! dyn_into {
($dyn : expr, $len : expr) => { ... };
}
Expand description
Convert Slice
/Vec
(Bytes
) to a type directly
Examples
#[derive(Debug, PartialEq)]
struct LJF([u8; 17]);
impl From<[u8; 17]> for LJF {
fn from(array: [u8; 17]) -> Self {
Self(array)
}
}
let ljf: LJF = array_bytes::dyn_into!(*b"Love Jane Forever Forever Forever", 17);
assert_eq!(ljf, LJF(*b"Love Jane Forever"));
let ljf: LJF = array_bytes::dyn_into!(b"Love Jane Forever Forever Forever".to_vec(), 17);
assert_eq!(ljf, LJF(*b"Love Jane Forever"));