pub trait Len {
const CAPACITY: Option<usize>;
// Required methods
fn len(&self) -> usize;
fn is_full(&self) -> bool;
// Provided method
fn is_empty(&self) -> bool { ... }
}
Expand description
Get the runtime size of some data structure
The maximum number of elements that this data structure can acommodate.
Get the runtime size (in bytes) of a struct
For collections this is always equivalent to calling an inherent len method.
use toad_common::GetSize;
assert_eq!(vec![1u8, 2].get_size(), 2)
Is there no room left in this collection?
use toad_common::GetSize;
let array = tinyvec::ArrayVec::<[u8; 2]>::from([1, 2]);
assert!(array.is_full())
Check if the runtime size is zero
use toad_common::GetSize;
assert!(Vec::<u8>::new().size_is_zero())