n_elements_for_bytes

Function n_elements_for_bytes 

Source
pub const fn n_elements_for_bytes<T>(n: usize) -> usize
Expand description

The maximun number of elements of type T, that can be stored on the given byte size

ยงExamples

use tiny_vec::n_elements_for_bytes;

assert_eq!(n_elements_for_bytes::<u8>(2), 2);
assert_eq!(n_elements_for_bytes::<u16>(4), 2);
assert_eq!(n_elements_for_bytes::<i32>(17), 4);