5 releases

0.1.5 Nov 3, 2024
0.1.4 Oct 28, 2024
0.1.2 Oct 14, 2024
0.1.1 Oct 14, 2024
0.1.0 Oct 12, 2024

#598 in Data structures

Download history 519/week @ 2024-10-12 32/week @ 2024-10-19 122/week @ 2024-10-26 133/week @ 2024-11-02 5/week @ 2024-11-09 8/week @ 2024-11-16 2/week @ 2024-11-23

150 downloads per month

MIT license

115KB
3K SLoC

Arbutus

Arbutus is a tree data structure library for Rust.

Overview

Arbutus provides a high-level API for constructing and manipulating trees, along with support for indexing and querying. The library focuses on simplicity, flexibility, and performance.

Features

  • Tree Construction: Build trees using the TreeBuilder API, which provides a composable way to construct tree structures.
  • Indexing: Utilize B-Tree indices for efficient querying and retrieval of node data.
  • Iterators: Traverse trees using iterators

Getting Started

To get started with Arbutus, add the following dependency to your Cargo.toml file:

[dependencies]
arbutus = "0.1.0"

Example of building a tree

// Custom errors can be propagated through the builder closures
#[derive(Debug)]
enum MyError {
    Fail(String),
}

#[derive(Debug)]
enum TestData {
    Foo,
    Bar,
    String(String),
    Baz,
}

let tree = TreeBuilder::<TestData, MyError>::new()
    .root(TestData::Foo, |foo| {
        debug!("Foo builder closure");

        foo.child(TestData::Bar, |bar| {
            debug!("Bar builder closure");
            bar.child(TestData::Baz, |_| Ok(()))
        })?;

        foo.child(TestData::String("Hello".into()), |_| Ok(()))?;

        Ok(())
    })
    .unwrap()
    .done();
info!("{tree:#?}");

License

Arbutus is released under the MIT license. See the LICENSE file for details.

Dependencies

~5–17MB
~166K SLoC