#[derive(Tree)]
{
// Attributes available to this derive:
#[tree]
}
Expand description
Derives Leaves and Tree for a struct (named, tuple or unit) or an enum: the type’s
array leaves get paths from its field names, as MLX’s tree_flatten.
ⓘ
#[derive(Clone, Tree)]
struct Batch { x: Array, y: Array, #[tree(skip)] len: usize }
#[derive(Clone, Tree)]
enum Either { A(Array), #[tree(rename = "b")] B(Vec<Array>), Empty }A newtype enum variant is transparent unless renamed; struct variants name their fields; every variant reports its index, so a leaf-less variant changes the structure. Type parameters are bounded only where a field uses them. Trait-object fields are rejected (use an enum of the concrete types).