Trait toad_common::array::GetSize
source · pub trait GetSize {
const CAPACITY: Option<usize>;
// Required methods
fn get_size(&self) -> usize;
fn is_full(&self) -> bool;
// Provided method
fn size_is_zero(&self) -> bool { ... }
}
Expand description
Get the runtime size of some data structure
Deprecated
Note: in a future version of toad_common
this will be deprecated in favor of clearly delineating
“size in bytes” (e.g. RuntimeSize
) from “collection of potentially bounded length” (e.g. Len
)
Collections
For collections this just yields the number of elements (Vec::len
, tinyvec::ArrayVec::len
),
and when the collection is over u8
s,
then get_size
represents the number of bytes in the collection.
Structs and enums
When implemented for items that are not collections,
this is expected to yield the runtime size in bytes
(not the static Rust core::mem::size_of
size)
Required Associated Constants§
Required Methods§
Provided Methods§
sourcefn size_is_zero(&self) -> bool
fn size_is_zero(&self) -> bool
Check if the runtime size is zero
use toad_common::GetSize;
assert!(Vec::<u8>::new().size_is_zero())