pub enum DepthFirstSequenceError {
NonZeroRootDepth,
DepthIncreaseGreaterThanOne {
depth: usize,
succeeding_depth: usize,
},
}
Expand description
A depth first sequence, or DepthFirstSequence
is simply a sequence of (usize, T)
tuples
corresponding to (depth, value) pairs of nodes of a tree which are ordered by the depth-first
traversal order.
Therefore, not all IntoIterator<Item = (usize, T)>
types satisfy the depth-first sequence
requirement.
The invalid sequences are represented by the DepthFirstSequenceError
type.
Variantsยง
NonZeroRootDepth
The first element of the depth-first sequence must be the root with depth 0. Therefore, any sequence with a first element having a non-zero depth leads to this error.
Note that empty sequences are valid and represent an empty tree.
DepthIncreaseGreaterThanOne
While traversing a tree in depth first order, we
- either move one level down to access the child (depth = previous depth + 1)
- or stay at the same level to access the sibling to the right (depth = previous depth)
- or move up and then right to access the next child of an ancestor (depth < previous depth)
This list represents valid depth transition. However, we never
- move n > 1 level down (depth > previous depth + 1)
This leaves a gap in the depth-first traversal, and hance, is the invalid case that this error variant represents.
Trait Implementationsยง
Sourceยงimpl Clone for DepthFirstSequenceError
impl Clone for DepthFirstSequenceError
Sourceยงfn clone(&self) -> DepthFirstSequenceError
fn clone(&self) -> DepthFirstSequenceError
1.0.0 ยท Sourceยงfn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more