Expand description
Fillet is a thin pointer based contiguous collection.
Fillet is null/zero when empty, and is especially well suited to scenarios where most
collections are empty, and you are storing references to many of them.
Fillet has specialized handling of Zero-Sized Types (ZSTs).
When T is zero-sized, Fillet<T> is a usize length, and Deref and Drop behaviors are
handled with dangling pointers.
Fillet is guaranteed to be pointer-sized, and is always zero (either None of NonNull or
0usize) when empty.
Fillet does not reserve capacity, and this means that repeated push can be slow since it
always calls the allocator, and always computes a Layout.
Fillet’s Extend and FromIterator use amortized growth and track capacity internally, so
are roughly equivalent in performance to the same implementations on Vec.
§Examples
§Basic Usage
use fillet::Fillet;
let mut f: Fillet<_> = (1..=3).collect();
assert_eq!(f.len(), 3);
assert_eq!(*f, [1, 2, 3]);
f.push(4);
assert_eq!(*f, [1, 2, 3, 4]);
f.truncate(2);
assert_eq!(*f, [1, 2]);§Zero-Sized Types
use fillet::Fillet;
use core::iter::repeat_n;
use core::mem::size_of;
let mut f: Fillet<()> = repeat_n((), 5).collect();
assert_eq!(f.len(), 5);
// No heap allocation
f.push(());
assert_eq!(f.len(), 6);
assert_eq!(size_of::<Fillet<()>>(), size_of::<usize>());§Extending from Within
use fillet::Fillet;
let mut f = Fillet::from([1, 2]);
f.extend_from_within(..);
assert_eq!(*f, [1, 2, 1, 2]);Structs§
- Fillet
Into Iter - A double-ended iterator over
Fillet<T>that consumes and drops the collection.
Unions§
- Fillet
- A thin pointer based contiguous collection.