small_len
A simple enum and trait to ensure that the value returned by small_len() is always the smallest representation. This is meant to be used by fn_vm to support "infinite" commands, arguments, and registers.
NOTE: This is primarily meant for dynamic sized objects, String, [T], &[T], Vec, HashMap, and IndexMap (with feature indexmap); if you need an optimization for static bounds at compile time check out the smallnum crate.
For a generic number crate check out varnum.
Usage
use SmallLen;
Features
default: No extra features, includes Vec and HashMap<K, V> implementations.bumpalo: AddsLenimplementation forbumpalo::Bump.bytes: AddsLenimplementation forbytes::Bytesandbytes::BytesMut.indexmap: AddsLenimplementation forindexmap::IndexMap.
Custom Types
If you need to add SmallLen to another type, you can implement the Len trait.
Additional Traits
The Length enum also implements the following traits for easier use (Length | SmallLength | usize):
- Index for Vec, this will panic if the index is out of bounds
- Add
- Div
- Mul
- Rem
- Sub
- Not
- BitAnd
- BitOr
- BitXor