#intrusive #rb-tree #list #no-std

no-std foyer-intrusive-collections

Intrusive collections for Rust (linked list and red-black tree)

1 unstable release

new 0.10.0-dev Dec 2, 2024

#749 in Data structures


Used in 4 crates (via foyer-memory)

Apache-2.0/MIT

355KB
8K SLoC

intrusive-collections

forked from Amanieu/intrusive-rs

Build Status Coverage Status Crates.io

A Rust library for creating intrusive collections. Currently supports singly-linked and doubly-linked lists, as well as red-black trees.

Features

  • Compatible with #[no_std].
  • Intrusive collections don't require any dynamic memory allocation since they simply keep track of existing objects rather than allocating new ones.
  • You can safely manipulate intrusive collections without any unsafe code.
  • A single object can be a member of multiple intrusive collections simultaneously.
  • Intrusive collections provide a Cursor-based interface, which allows safe mutation while iterating.

For examples and more information, see the documentation (crates.io, master).

Usage

Add this to your Cargo.toml:

[dependencies]
intrusive-collections = { package = "foyer-intrusive-collections", version = "0.10.0-dev" }

This crate has two Cargo features:

  • nightly: Enables nightly-only features: const fn constructors for collections (Link constructors are always const fn)
  • alloc (enabled by default): Implements IntrusivePointer for Box, Rc and Arc.

License

Licensed under either of

at your option.

Contribution

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 dual licensed as above, without any additional terms or conditions.

Dependencies