fillet 0.1.0

An efficient thin pointer based contiguous collection.
Documentation
  • Coverage
  • 93.75%
    15 out of 16 items documented1 out of 14 items with examples
  • Size
  • Source code size: 120.43 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 5.44 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 13s Average build duration of successful builds.
  • all releases: 13s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • xorgy/fillet
    1 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • xorgy

Fillet

A thin pointer based contiguous collection.

ISC or Apache 2.0 or MIT license. Build status Crates.io Docs

Fillet is null/zero when empty, making it ideal for scenarios where most collections are empty and you're storing many references to them. It handles zero-sized types (ZSTs) without heap allocations, using usize for length.

Fillet is always pointer-sized and zero when empty.

Fillet does not reserve capacity, so repeated push operations can be slow as they always invoke the allocator and compute layouts. However, Extend and FromIterator use amortized growth and perform similarly to Vec.

This crate is no_std.

Features

  • Same stack size and alignment as a thin pointer.
  • Very efficient for empty collections.
  • Fast from_iter/collect and extend, without reserved capacity.
  • Performance similar to Vec in most cases.
  • No dependencies outside core and alloc.

Examples

Basic Usage

use fillet::Fillet;

let mut f: Fillet<i32> = Fillet::from([1, 2, 3]);
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]);

Minimum Supported Rust Version (MSRV)

Fillet has been verified to compile with Rust 1.85 and later.

Future versions might increase the Rust version requirement. It will not be treated as a breaking change, and as such can even happen with small patch releases.

License

Triple licensed, at your option:

Contribution

Contributions are welcome by pull request or email. Please feel free to add your name to the AUTHORS file in any substantive pull request.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be licensed as above, without any additional terms or conditions.