orx_tree/traversal/
over_mut.rs

1use super::{
2    enumeration::Enumeration,
3    node_item_mut::NodeItemMut,
4    over::{Over, OverData, OverDepthData, OverDepthSiblingIdxData, OverSiblingIdxData},
5};
6use crate::{
7    TreeVariant,
8    memory::{Auto, MemoryPolicy},
9    pinned_storage::{PinnedStorage, SplitRecursive},
10};
11use orx_selfref_col::Variant;
12
13pub type OverItemMut<'a, V, O, M = Auto, P = SplitRecursive> =
14    <<O as Over>::Enumeration as Enumeration>::Item<<O as OverMut>::NodeItemMut<'a, V, M, P>>;
15
16pub type OverItemInto<'a, V, O> =
17    <<O as Over>::Enumeration as Enumeration>::Item<<V as Variant>::Item>;
18
19/// Type that defines the type of the mutable items that iterators created by a traverser such as the [`Dfs`] or [`PostOrder`].
20///
21/// [`Dfs`]: crate::traversal::Dfs
22/// [`PostOrder`]: crate::traversal::PostOrder
23pub trait OverMut: Over {
24    /// Part of the mutable iterator item which only depends on the node's internal data.
25    type NodeItemMut<'a, V, M, P>: NodeItemMut<'a, V, M, P>
26    where
27        M: MemoryPolicy,
28        P: PinnedStorage,
29        V: TreeVariant + 'a,
30        Self: 'a;
31}
32
33// val
34
35impl OverMut for OverData {
36    type NodeItemMut<'a, V, M, P>
37        = &'a mut V::Item
38    where
39        M: MemoryPolicy,
40        P: PinnedStorage,
41        V: TreeVariant + 'a,
42        Self: 'a;
43}
44
45// depth & val
46
47impl OverMut for OverDepthData {
48    type NodeItemMut<'a, V, M, P>
49        = &'a mut V::Item
50    where
51        M: MemoryPolicy,
52        P: PinnedStorage,
53        V: TreeVariant + 'a,
54        Self: 'a;
55}
56
57// sibling & val
58
59impl OverMut for OverSiblingIdxData {
60    type NodeItemMut<'a, V, M, P>
61        = &'a mut V::Item
62    where
63        M: MemoryPolicy,
64        P: PinnedStorage,
65        V: TreeVariant + 'a,
66        Self: 'a;
67}
68
69// depth & sibling & val
70
71impl OverMut for OverDepthSiblingIdxData {
72    type NodeItemMut<'a, V, M, P>
73        = &'a mut V::Item
74    where
75        M: MemoryPolicy,
76        P: PinnedStorage,
77        V: TreeVariant + 'a,
78        Self: 'a;
79}