Expand description
A library for displaying Rust data structures as syntax-highlighted trees.
tree-display provides a simple derive macro (#[derive(TreeDisplay)])
to render any data structure as a beautifully formatted tree in the terminal.
Features include syntax highlighting, custom value mapping, and full theming support.
§Quick Start
use tree_display::{TreeDisplay, Formatter};
#[derive(Debug, TreeDisplay)]
struct Person {
name: String,
age: u32,
}
let person = Person {
name: "Alice".to_string(),
age: 30,
};
println!("{}", Formatter::of(&person).format());§Features
- Derive macro:
#[derive(TreeDisplay)]for automatic tree generation - Field attributes: Control rendering of individual fields:
#[tree(map)]- Apply a custom mapper fromContext#[tree(ignore)]- Exclude a field from the tree#[tree(label = "...")]- Override the field’s display label#[tree(unlabeled)]- Display the field without a label
- Custom mapping: Transform values with
Contextmappers - Theming: Predefined themes (VS Code Dark+, Solarized, etc.)
- Color support: Optional ANSI color highlighting
- Line styles: ASCII or Unicode box-drawing characters
- Formatting: Labels, alignment, and custom content types
Re-exports§
pub use color::Colors;pub use context::Context;pub use format::Formatter;pub use graphics::Graphics;pub use theme::Theme;
Modules§
- color
- Colors used for drawing tree structures in the terminal.
- context
- Custom value transformations for tree display.
- format
- Tree rendering and formatting.
- graphics
- Line characters used for drawing tree structures in the terminal.
- support
- Implementations of
TreeDisplayfor common Rust types. - theme
- Color and line graphics bundled into a cohesive visual style.
Structs§
- Tree
- A tree node containing content and child subtrees.
Traits§
- Tree
Display - A type that can be displayed as a tree.
Derive Macros§
- Tree
Display - Derives
TreeDisplayfor structs and enums.