pub trait Nested: Sized {
const LEAF: Self;
// Required methods
fn parts(&self) -> impl DoubleEndedIterator<Item = &Self>;
fn parts_mut(&mut self) -> impl Iterator<Item = &mut Self>;
// Provided methods
fn fold<F: Fold<Self>>(&self, fold: &mut F) -> F::Made { ... }
fn same_tree(
&self,
other: &Self,
same_node: impl FnMut(&Self, &Self) -> bool,
) -> bool { ... }
fn free_parts(&mut self) { ... }
}Expand description
A tree whose nodes each hold their parts, nested to no bound.
Required Associated Constants§
Required Methods§
Sourcefn parts(&self) -> impl DoubleEndedIterator<Item = &Self>
fn parts(&self) -> impl DoubleEndedIterator<Item = &Self>
The nodes self is made of, in order.
Sourcefn parts_mut(&mut self) -> impl Iterator<Item = &mut Self>
fn parts_mut(&mut self) -> impl Iterator<Item = &mut Self>
The parts only self holds, in Nested::parts order, for moving
out: none of those it shares with another tree.
Provided Methods§
Sourcefn fold<F: Fold<Self>>(&self, fold: &mut F) -> F::Made
fn fold<F: Fold<Self>>(&self, fold: &mut F) -> F::Made
What fold makes of self, built bottom-up.
Each node is offered to Fold::open once, in pre-order, its parts
in Nested::parts order, and a node it opens is joined from what
its parts make. It takes time linear in the nodes opened, and the
native stack stays bounded however deep self is.
Sourcefn same_tree(
&self,
other: &Self,
same_node: impl FnMut(&Self, &Self) -> bool,
) -> bool
fn same_tree( &self, other: &Self, same_node: impl FnMut(&Self, &Self) -> bool, ) -> bool
Whether self and other are alike node by node, by same_node,
which says whether two nodes are alike on their own, with as many
parts: with each node’s count of parts, pre-order spells the tree.
Sourcefn free_parts(&mut self)
fn free_parts(&mut self)
Frees each part only self holds that has parts of its own, leaving
Nested::LEAF in its place: what dropping self does first, so a
tree nested however deep drops on a native stack of fixed size.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".