Skip to main content

Module const_vec

Module const_vec 

Source
Expand description

A fixed-size inline vector with const generic capacity.

§Features

  • It’s smaller in size than std::vec::Vec.
  • push returns errors when the capacity is exceeded instead of reallocating.
  • No heap allocation after initial creation, better cache consistency

§Example

use embed_collections::const_vec::ConstVec;

let mut vec: ConstVec<i32, 3> = ConstVec::new();

assert!(vec.push(1).is_ok());
assert!(vec.push(2).is_ok());
assert!(vec.push(3).is_ok());

// Capacity is full, next push returns Err
assert!(vec.push(4).is_err());

assert_eq!(vec.len(), 3);
assert_eq!(vec.capacity(), 3);

Structs§

ConstVec
A fixed-size inline vector with const generic capacity