pub const fn from_bytes<T: Pod, const N: usize>(val: &[u8; N]) -> T
Expand description

Reads N bytes from Pod object by performing memcpy

Usage

use lazy_bytes_cast::from_bytes;

const INPUT: u32 = 500_900_100;
const RES: u32 = from_bytes(&INPUT.to_ne_bytes());
assert_eq!(RES, INPUT);

Restrictions

Compilation fails if val is not the same size as output.

use lazy_bytes_cast::from_bytes;

let res: u32 = from_bytes(&[1, 2, 3]);