orx_tree/errors.rs
1use orx_selfref_col::NodeIdxError;
2
3/// Error variants that can be observed while swapping two subtrees rooted at two
4/// nodes of the tree.
5#[derive(Clone, Copy, Debug, PartialEq)]
6pub enum NodeSwapError {
7 /// At least one of the indices of the roots of the two subtrees is invalid.
8 NodeIdxError(NodeIdxError),
9 /// The first node is an ancestor of the second node; and hence, the subtrees
10 /// intersect.
11 /// The subtrees must be independent to have a valid swap operation.
12 FirstNodeIsAncestorOfSecond,
13 /// The second node is an ancestor of the first node; and hence, the subtrees
14 /// intersect.
15 /// The subtrees must be independent to have a valid swap operation.
16 SecondNodeIsAncestorOfFirst,
17}
18
19impl From<NodeIdxError> for NodeSwapError {
20 fn from(value: NodeIdxError) -> Self {
21 Self::NodeIdxError(value)
22 }
23}