rs-intrusive - Support macros for building intrusive data structures
in Rust.
An intrusive structure is a general-purpose structure directly embedded within a containing structure, in order to add that general-purpose facility to the container. As an example, one might use an intrusive "link" structure to allow objects to be organized in a linked-list:
While this module does not provide a linked-list implementation (for separation-of-concerns reasons, I believe a linked-list implementation belongs in a separate crate), it does provide some necessary abstractions for using intrusive structures:
- The
field_offset!macro, which identifies the location of a field in a containing structure. This isn't too useful in itself, but is necessary to support: - The
intrusive!macro, which provides a newtype for using "intrusive" fields to work with the container object.
Usage
extern crate "intrusive";
// FIXME: is this legal? want to enforce constraint that `List` only
// operates against intrusive `Link`s.
struct<T> where
T: ,
Field: Link,
intrusive!;
Contributing
- Fork it ( https://github.com/aidancully/rs-intrusive/fork )
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request