34 releases

Uses new Rust 2024

new 0.3.0-beta.2 Apr 15, 2026
0.3.0-beta.1 Apr 8, 2026
0.2.5 Mar 29, 2026
0.1.9 Feb 13, 2026
0.1.0-alpha.1 Dec 21, 2025

#21 in #tree-traversal

44 downloads per month
Used in 12 crates (via brk_traversable)

MIT license

38KB
835 lines

brk_traversable_derive

Proc-macro for deriving the Traversable trait on data structures.

What It Enables

Automatically generate tree traversal and export iteration for structs, eliminating boilerplate when working with hierarchical data that needs serialization or inspection.

Key Features

  • Automatic tree building: Converts struct fields into TreeNode::Branch hierarchies
  • Export iteration: Generates iter_any_exportable() to walk all exportable vectors
  • Field attributes: #[traversable(skip)] to exclude fields, #[traversable(flatten)] to merge nested structures
  • Option support: Gracefully handles Option<T> fields
  • Generic-aware: Properly bounds generic parameters with Traversable + Send + Sync

Core API

#[derive(Traversable)]
struct MyData {
    pub metrics: MetricsCollection,
    #[traversable(flatten)]
    pub nested: NestedData,
    #[traversable(skip)]
    internal: Cache,
}

Generated Methods

  • to_tree_node(&self) -> TreeNode - Build navigable tree structure
  • iter_any_exportable(&self) -> impl Iterator<Item = &dyn AnyExportableVec> - Iterate all exportable vectors

Dependencies

~105–460KB
~11K SLoC