Function fuel_types::bytes::from_loc_ref

source ·
pub fn from_loc_ref<const ARR: usize, const ADDR: usize, const SIZE: usize>(
    _layout: MemLoc<ADDR, SIZE>,
    buf: &[u8; ARR]
) -> &[u8; SIZE]
Expand description

Get a fixed sized slice from a specific location in a fixed sized slice. Won’t compile if the buffer is not large enough.

let mem = [0u8; 32];
let _: &[u8; 2] = from_loc_ref(MemLoc::<1, 2>::new(), &mem);
let mem = [0u8; 32];
let _: &[u8; 2] = from_loc_ref(MemLoc::<31, 2>::new(), &mem);
let mem = [0u8; 32];
let _: &[u8; 2] = from_loc_ref(MemLoc::<34, 2>::new(), &mem);