FixedVec
implements PinnedVec
; therefore,
This feature eliminates a specific set of errors leading to undefined behavior, and hence, allows to work with a more flexible borrow checker.
Furthermore, it can be used as the underlying pinned vector of an
ImpVec
, which adds the additional feature
to push to the vector with an immutable reference.
Unlike, another pinned vector implementation SplitVec
,
FixedVec
allows operations with same complexity and speed of std::vec::Vec
.
Its drawback, on the other hand, is that:
```rust use orxfixedvec::prelude::*;
let fixedcapacity = 42; let mut vec = FixedVec::new(fixedcapacity); asserteq!(fixedcapacity, vec.capacity());
let mut initialaddresses = vec![]; for i in 0..fixedcapacity { vec.push(i); initial_addresses.push(vec.get(i).unwrap() as *const usize); }
asserteq!(fixedcapacity, vec.len()); asserteq!(0, vec.room()); assert!(vec.isfull());
// addresses of already pushed elements stay intact let finaladdresses: Vec<_> = (0..fixedcapacity) .map(|i| vec.get(i).unwrap() as *const usize) .collect(); asserteq!(initialaddresses, final_addresses);
// the next push when vec.is_full()
panics!
// vec.push(42);
```