| 1 | #![allow(clippy::if_same_then_else)] |
| 2 | /// DIAGRAM of terminology |
| 3 | /// A |
| 4 | /// /\ |
| 5 | /// B C |
| 6 | /// | |\ |
| 7 | /// D E F |
| 8 | /// |\/| | |
| 9 | /// |/\|/ |
| 10 | /// G H |
| 11 | /// |
| 12 | /// In this diagram, relative to G and H: |
| 13 | /// A, B, C, D, E are common ancestors. |
| 14 | /// C, D and E are border ancestors, because each has a non-common descendant. |
| 15 | /// D and E are least common ancestors because none of their descendants are |
| 16 | /// common ancestors. |
| 17 | /// C is not a least common ancestor because its descendant, E, is a common |
| 18 | /// ancestor. |
| 19 | /// |
| 20 | /// The find_unique_lca algorithm will pick A in two steps: |
| 21 | /// 1. find_lca('G', 'H') => ['D', 'E'] |
| 22 | /// 2. Since len(['D', 'E']) > 1, find_lca('D', 'E') => ['A'] |
| 23 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::collectionsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/::{HashMaprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/HashMap#, HashSetrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/HashSet#}; |
| 24 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::hashrust-analyzer cargo std https://github.com/rust-lang/rust/library/std hash/::Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hash#; |
| 25 | |
| 26 | pub mod bfsrust-analyzer cargo vcs-graph 3.6.0 bfs/; |
| 27 | pub use bfsrust-analyzer cargo vcs-graph 3.6.0 bfs/::BfsStaterust-analyzer cargo vcs-graph 3.6.0 bfs/BfsState#; |
| 28 | pub mod graphrust-analyzer cargo vcs-graph 3.6.0 graph/; |
| 29 | pub use graphrust-analyzer cargo vcs-graph 3.6.0 graph/::{Graphrust-analyzer cargo vcs-graph 3.6.0 graph/Graph#, GraphErrorrust-analyzer cargo vcs-graph 3.6.0 graph/GraphError#}; |
| 30 | pub mod known_graphrust-analyzer cargo vcs-graph 3.6.0 known_graph/; |
| 31 | pub use known_graphrust-analyzer cargo vcs-graph 3.6.0 known_graph/::{Keyrust-analyzer cargo vcs-graph 3.6.0 known_graph/Key#, KnownGraphrust-analyzer cargo vcs-graph 3.6.0 known_graph/KnownGraph#, MergeSortNoderust-analyzer cargo vcs-graph 3.6.0 known_graph/MergeSortNode#}; |
| 32 | mod parents_providerrust-analyzer cargo vcs-graph 3.6.0 parents_provider/; |
| 33 | pub use parents_providerrust-analyzer cargo vcs-graph 3.6.0 parents_provider/::{ |
| 34 | CachingParentsProviderrust-analyzer cargo vcs-graph 3.6.0 parents_provider/CachingParentsProvider#, DictParentsProviderrust-analyzer cargo vcs-graph 3.6.0 parents_provider/DictParentsProvider#, ParentsProviderrust-analyzer cargo vcs-graph 3.6.0 parents_provider/ParentsProvider#, StackedParentsProviderrust-analyzer cargo vcs-graph 3.6.0 parents_provider/StackedParentsProvider#, |
| 35 | }; |
| 36 | |
| 37 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:)] |
| 38 | pub enum Parentsrust-analyzer cargo vcs-graph 3.6.0 Parents#<K: Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone# + PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq# + Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq#> { |
| 39 | Ghostrust-analyzer cargo vcs-graph 3.6.0 Parents#Ghost#, |
| 40 | Knownrust-analyzer cargo vcs-graph 3.6.0 Parents#Known#(Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<K>), |
| 41 | } |
| 42 | |
| 43 | impl<K: Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone# + PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq# + Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq#> Parentsrust-analyzer cargo vcs-graph 3.6.0 Parents#<K> { |
| 44 | pub fn is_ghostrust-analyzer cargo vcs-graph 3.6.0 impl#[`Parents<K>`]is_ghost().(&self) -> bool { |
| 45 | match self { |
| 46 | Parentsrust-analyzer cargo vcs-graph 3.6.0 Parents#::Ghostrust-analyzer cargo vcs-graph 3.6.0 Parents#Ghost# => true, |
| 47 | Parentsrust-analyzer cargo vcs-graph 3.6.0 Parents#::Knownrust-analyzer cargo vcs-graph 3.6.0 Parents#Known#(_) => false, |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | pub fn is_knownrust-analyzer cargo vcs-graph 3.6.0 impl#[`Parents<K>`]is_known().(&self) -> bool { |
| 52 | match self { |
| 53 | Parentsrust-analyzer cargo vcs-graph 3.6.0 Parents#::Ghostrust-analyzer cargo vcs-graph 3.6.0 Parents#Ghost# => false, |
| 54 | Parentsrust-analyzer cargo vcs-graph 3.6.0 Parents#::Knownrust-analyzer cargo vcs-graph 3.6.0 Parents#Known#(_) => true, |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | pub fn unwraprust-analyzer cargo vcs-graph 3.6.0 impl#[`Parents<K>`]unwrap().(&self) -> Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<K> { |
| 59 | match self { |
| 60 | Parentsrust-analyzer cargo vcs-graph 3.6.0 Parents#::Ghostrust-analyzer cargo vcs-graph 3.6.0 Parents#Ghost# => panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("unwrap called on Ghost"), |
| 61 | Parentsrust-analyzer cargo vcs-graph 3.6.0 Parents#::Knownrust-analyzer cargo vcs-graph 3.6.0 Parents#Known#(v) => v.clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][Clone]clone().(), |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | /// Borrow the known parents as a slice without cloning. |
| 66 | /// |
| 67 | /// Panics if this is a `Ghost`. |
| 68 | pub fn as_slicerust-analyzer cargo vcs-graph 3.6.0 impl#[`Parents<K>`]as_slice().(&self) -> &[K] { |
| 69 | match self { |
| 70 | Parentsrust-analyzer cargo vcs-graph 3.6.0 Parents#::Ghostrust-analyzer cargo vcs-graph 3.6.0 Parents#Ghost# => panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("as_slice called on Ghost"), |
| 71 | Parentsrust-analyzer cargo vcs-graph 3.6.0 Parents#::Knownrust-analyzer cargo vcs-graph 3.6.0 Parents#Known#(v) => v.as_slicerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]as_slice().(), |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | pub fn as_refrust-analyzer cargo vcs-graph 3.6.0 impl#[`Parents<K>`]as_ref().(&self) -> Parentsrust-analyzer cargo vcs-graph 3.6.0 Parents#<&K> { |
| 76 | match self { |
| 77 | Parentsrust-analyzer cargo vcs-graph 3.6.0 Parents#::Ghostrust-analyzer cargo vcs-graph 3.6.0 Parents#Ghost# => Parentsrust-analyzer cargo vcs-graph 3.6.0 Parents#::Ghostrust-analyzer cargo vcs-graph 3.6.0 Parents#Ghost#, |
| 78 | Parentsrust-analyzer cargo vcs-graph 3.6.0 Parents#::Knownrust-analyzer cargo vcs-graph 3.6.0 Parents#Known#(v) => Parentsrust-analyzer cargo vcs-graph 3.6.0 Parents#::Knownrust-analyzer cargo vcs-graph 3.6.0 Parents#Known#(v.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().()), |
| 79 | } |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | #[cfg(feature = "pyo3")] |
| 84 | impl<'py, K: pyo3rust-analyzer cargo pyo3 0.28.3 crate/::IntoPyObjectrust-analyzer cargo pyo3 0.28.3 conversion/IntoPyObject#<'py> + Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone# + PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq# + Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq#> pyo3rust-analyzer cargo pyo3 0.28.3 crate/::IntoPyObjectrust-analyzer cargo pyo3 0.28.3 conversion/IntoPyObject#<'py> |
| 85 | for Parentsrust-analyzer cargo vcs-graph 3.6.0 Parents#<K> |
| 86 | { |
| 87 | type Targetrust-analyzer cargo vcs-graph 3.6.0 impl#[`Parents<K>`][`IntoPyObject<'py>`]Target# = pyo3rust-analyzer cargo pyo3 0.28.3 crate/::typesrust-analyzer cargo pyo3 0.28.3 types/::PyAnyrust-analyzer cargo pyo3 0.28.3 types/any/PyAny#; |
| 88 | |
| 89 | type Outputrust-analyzer cargo vcs-graph 3.6.0 impl#[`Parents<K>`][`IntoPyObject<'py>`]Output# = pyo3rust-analyzer cargo pyo3 0.28.3 crate/::Boundrust-analyzer cargo pyo3 0.28.3 instance/Bound#<'py, Selfrust-analyzer cargo vcs-graph 3.6.0 impl#[`Parents<K>`][`IntoPyObject<'py>`]::Targetrust-analyzer cargo pyo3 0.28.3 conversion/IntoPyObject#Target#>; |
| 90 | |
| 91 | type Errorrust-analyzer cargo vcs-graph 3.6.0 impl#[`Parents<K>`][`IntoPyObject<'py>`]Error# = pyo3rust-analyzer cargo pyo3 0.28.3 crate/::PyErrrust-analyzer cargo pyo3 0.28.3 err/PyErr#; |
| 92 | |
| 93 | fn into_pyobjectrust-analyzer cargo vcs-graph 3.6.0 impl#[`Parents<K>`][`IntoPyObject<'py>`]into_pyobject().(self, py: pyo3rust-analyzer cargo pyo3 0.28.3 crate/::Pythonrust-analyzer cargo pyo3 0.28.3 marker/Python#<'py>) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo vcs-graph 3.6.0 impl#[`Parents<K>`][`IntoPyObject<'py>`]::Outputrust-analyzer cargo pyo3 0.28.3 conversion/IntoPyObject#Output#, Selfrust-analyzer cargo vcs-graph 3.6.0 impl#[`Parents<K>`][`IntoPyObject<'py>`]::Errorrust-analyzer cargo pyo3 0.28.3 conversion/IntoPyObject#Error#> { |
| 94 | match self { |
| 95 | Parentsrust-analyzer cargo vcs-graph 3.6.0 Parents#::Ghostrust-analyzer cargo vcs-graph 3.6.0 Parents#Ghost# => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(py.Nonerust-analyzer cargo pyo3 0.28.3 marker/impl#[`Python<'py>`]None().().into_pyobjectrust-analyzer cargo pyo3 0.28.3 conversion/impl#[`Py<T>`][`IntoPyObject<'py>`]into_pyobject().(py)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().), |
| 96 | Parentsrust-analyzer cargo vcs-graph 3.6.0 Parents#::Knownrust-analyzer cargo vcs-graph 3.6.0 Parents#Known#(v) => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(pyo3rust-analyzer cargo pyo3 0.28.3 crate/::typesrust-analyzer cargo pyo3 0.28.3 types/::PyTuplerust-analyzer cargo pyo3 0.28.3 types/tuple/PyTuple#::newrust-analyzer cargo pyo3 0.28.3 types/tuple/impl#[PyTuple]new().(py, v)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()..into_anyrust-analyzer cargo pyo3 0.28.3 instance/impl#[`Bound<'py, T>`]into_any().()), |
| 97 | } |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | #[cfg(feature = "pyo3")] |
| 102 | impl<'py, K: pyo3rust-analyzer cargo pyo3 0.28.3 crate/::conversionrust-analyzer cargo pyo3 0.28.3 conversion/::FromPyObjectOwnedrust-analyzer cargo pyo3 0.28.3 conversion/FromPyObjectOwned#<'py> + Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone# + PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq# + Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq#> |
| 103 | pyo3rust-analyzer cargo pyo3 0.28.3 crate/::FromPyObjectrust-analyzer cargo pyo3 0.28.3 conversion/FromPyObject#<'_, 'py> for Parentsrust-analyzer cargo vcs-graph 3.6.0 Parents#<K> |
| 104 | { |
| 105 | type Errorrust-analyzer cargo vcs-graph 3.6.0 impl#[`Parents<K>`][`FromPyObject<'_, 'py>`]Error# = pyo3rust-analyzer cargo pyo3 0.28.3 crate/::PyErrrust-analyzer cargo pyo3 0.28.3 err/PyErr#; |
| 106 | |
| 107 | fn extractrust-analyzer cargo vcs-graph 3.6.0 impl#[`Parents<K>`][`FromPyObject<'_, 'py>`]extract().(obj: pyo3rust-analyzer cargo pyo3 0.28.3 crate/::Borrowedrust-analyzer cargo pyo3 0.28.3 instance/Borrowed#<'_, 'py, pyo3rust-analyzer cargo pyo3 0.28.3 crate/::PyAnyrust-analyzer cargo pyo3 0.28.3 types/any/PyAny#>) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo vcs-graph 3.6.0 impl#[`Parents<K>`][`FromPyObject<'_, 'py>`], Selfrust-analyzer cargo vcs-graph 3.6.0 impl#[`Parents<K>`][`FromPyObject<'_, 'py>`]::Errorrust-analyzer cargo pyo3 0.28.3 conversion/FromPyObject#Error#> { |
| 108 | use pyo3rust-analyzer cargo pyo3 0.28.3 crate/::preluderust-analyzer cargo pyo3 0.28.3 prelude/::*; |
| 109 | if obj.is_nonerust-analyzer cargo pyo3 0.28.3 types/any/impl#[`Bound<'py, PyAny>`][`PyAnyMethods<'py>`]is_none().() { |
| 110 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Parentsrust-analyzer cargo vcs-graph 3.6.0 Parents#::Ghostrust-analyzer cargo vcs-graph 3.6.0 Parents#Ghost#) |
| 111 | } else { |
| 112 | let v = obj.extractrust-analyzer cargo pyo3 0.28.3 instance/impl#[`Borrowed<'a, 'py, T>`]extract().::<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<K>>()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 113 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Parentsrust-analyzer cargo vcs-graph 3.6.0 Parents#::Knownrust-analyzer cargo vcs-graph 3.6.0 Parents#Known#(v)) |
| 114 | } |
| 115 | } |
| 116 | } |
| 117 | |
| 118 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:)] |
| 119 | pub struct ParentMaprust-analyzer cargo vcs-graph 3.6.0 ParentMap#<K: Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hash# + Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone# + PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq# + Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq#>(HashMaprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/HashMap#<K, Parentsrust-analyzer cargo vcs-graph 3.6.0 Parents#<K>>); |
| 120 | |
| 121 | impl<K: Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone# + Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hash# + PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq# + Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq#> ParentMaprust-analyzer cargo vcs-graph 3.6.0 ParentMap#<K> { |
| 122 | pub fn newrust-analyzer cargo vcs-graph 3.6.0 impl#[`ParentMap<K>`]new().() -> Selfrust-analyzer cargo vcs-graph 3.6.0 impl#[`ParentMap<K>`] { |
| 123 | ParentMaprust-analyzer cargo vcs-graph 3.6.0 ParentMap#(HashMaprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/HashMap#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V>`]new().()) |
| 124 | } |
| 125 | |
| 126 | #[inline] |
| 127 | pub fn insertrust-analyzer cargo vcs-graph 3.6.0 impl#[`ParentMap<K>`]insert().(&mut self, k: K, v: Parentsrust-analyzer cargo vcs-graph 3.6.0 Parents#<K>) { |
| 128 | self.0rust-analyzer cargo vcs-graph 3.6.0 ParentMap#0..insertrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]insert().(k, v); |
| 129 | } |
| 130 | |
| 131 | #[inline] |
| 132 | pub fn getrust-analyzer cargo vcs-graph 3.6.0 impl#[`ParentMap<K>`]get().(&self, k: &K) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&Parentsrust-analyzer cargo vcs-graph 3.6.0 Parents#<K>> { |
| 133 | self.0rust-analyzer cargo vcs-graph 3.6.0 ParentMap#0..getrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]get().(k) |
| 134 | } |
| 135 | |
| 136 | #[inline] |
| 137 | pub fn get_key_valuerust-analyzer cargo vcs-graph 3.6.0 impl#[`ParentMap<K>`]get_key_value().(&self, k: &K) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<(&K, &Parentsrust-analyzer cargo vcs-graph 3.6.0 Parents#<K>)> { |
| 138 | self.0rust-analyzer cargo vcs-graph 3.6.0 ParentMap#0..get_key_valuerust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]get_key_value().(k) |
| 139 | } |
| 140 | |
| 141 | #[inline] |
| 142 | pub fn iterrust-analyzer cargo vcs-graph 3.6.0 impl#[`ParentMap<K>`]iter().(&self) -> impl Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item# = (&K, &Parentsrust-analyzer cargo vcs-graph 3.6.0 Parents#<K>)> { |
| 143 | self.0rust-analyzer cargo vcs-graph 3.6.0 ParentMap#0..iterrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]iter().() |
| 144 | } |
| 145 | |
| 146 | #[inline] |
| 147 | pub fn contains_keyrust-analyzer cargo vcs-graph 3.6.0 impl#[`ParentMap<K>`]contains_key().(&self, k: &K) -> bool { |
| 148 | self.0rust-analyzer cargo vcs-graph 3.6.0 ParentMap#0..contains_keyrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]contains_key().(k) |
| 149 | } |
| 150 | |
| 151 | #[inline] |
| 152 | pub fn keysrust-analyzer cargo vcs-graph 3.6.0 impl#[`ParentMap<K>`]keys().(&self) -> impl Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item# = &K> { |
| 153 | self.0rust-analyzer cargo vcs-graph 3.6.0 ParentMap#0..keysrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]keys().() |
| 154 | } |
| 155 | |
| 156 | #[inline] |
| 157 | pub fn valuesrust-analyzer cargo vcs-graph 3.6.0 impl#[`ParentMap<K>`]values().(&self) -> impl Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item# = &Parentsrust-analyzer cargo vcs-graph 3.6.0 Parents#<K>> { |
| 158 | self.0rust-analyzer cargo vcs-graph 3.6.0 ParentMap#0..valuesrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]values().() |
| 159 | } |
| 160 | |
| 161 | #[inline] |
| 162 | pub fn lenrust-analyzer cargo vcs-graph 3.6.0 impl#[`ParentMap<K>`]len().(&self) -> usize { |
| 163 | self.0rust-analyzer cargo vcs-graph 3.6.0 ParentMap#0..lenrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]len().() |
| 164 | } |
| 165 | |
| 166 | #[inline] |
| 167 | pub fn removerust-analyzer cargo vcs-graph 3.6.0 impl#[`ParentMap<K>`]remove().(&mut self, k: &K) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Parentsrust-analyzer cargo vcs-graph 3.6.0 Parents#<K>> { |
| 168 | self.0rust-analyzer cargo vcs-graph 3.6.0 ParentMap#0..removerust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]remove().(k) |
| 169 | } |
| 170 | |
| 171 | #[inline] |
| 172 | pub fn is_emptyrust-analyzer cargo vcs-graph 3.6.0 impl#[`ParentMap<K>`]is_empty().(&self) -> bool { |
| 173 | self.0rust-analyzer cargo vcs-graph 3.6.0 ParentMap#0..is_emptyrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]is_empty().() |
| 174 | } |
| 175 | |
| 176 | #[inline] |
| 177 | pub fn extendrust-analyzer cargo vcs-graph 3.6.0 impl#[`ParentMap<K>`]extend().(&mut self, other: ParentMaprust-analyzer cargo vcs-graph 3.6.0 ParentMap#<K>) { |
| 178 | self.0rust-analyzer cargo vcs-graph 3.6.0 ParentMap#0..extendrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`][`Extend<(K, V)>`]extend().(other.0rust-analyzer cargo vcs-graph 3.6.0 ParentMap#0.); |
| 179 | } |
| 180 | } |
| 181 | |
| 182 | impl<K: Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hash# + Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone# + PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq# + Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq#> Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default# for ParentMaprust-analyzer cargo vcs-graph 3.6.0 ParentMap#<K> { |
| 183 | fn defaultrust-analyzer cargo vcs-graph 3.6.0 impl#[`ParentMap<K>`][Default]default().() -> Selfrust-analyzer cargo vcs-graph 3.6.0 impl#[`ParentMap<K>`][Default] { |
| 184 | Selfrust-analyzer cargo vcs-graph 3.6.0 impl#[`ParentMap<K>`][Default]::newrust-analyzer cargo vcs-graph 3.6.0 impl#[`ParentMap<K>`]new().() |
| 185 | } |
| 186 | } |
| 187 | |
| 188 | impl<K: Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hash# + Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone# + PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq# + Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq#> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<ParentMaprust-analyzer cargo vcs-graph 3.6.0 ParentMap#<K>> for HashMaprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/HashMap#<K, Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<K>> { |
| 189 | fn fromrust-analyzer cargo vcs-graph 3.6.0 impl#[`HashMap<K, Vec<K>>`][`From<ParentMap<K>>`]from().(map: ParentMaprust-analyzer cargo vcs-graph 3.6.0 ParentMap#<K>) -> Selfrust-analyzer cargo vcs-graph 3.6.0 impl#[`HashMap<K, Vec<K>>`][`From<ParentMap<K>>`] { |
| 190 | map.0rust-analyzer cargo vcs-graph 3.6.0 ParentMap#0. |
| 191 | .into_iterrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`][IntoIterator]into_iter().() |
| 192 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|(k, v)| (k, v.unwraprust-analyzer cargo vcs-graph 3.6.0 impl#[`Parents<K>`]unwrap().())) |
| 193 | .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<HashMaprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/HashMap#<K, Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<K>>>() |
| 194 | } |
| 195 | } |
| 196 | |
| 197 | impl<K: Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hash# + Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone# + PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq# + Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq#> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<HashMaprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/HashMap#<K, Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<K>>> for ParentMaprust-analyzer cargo vcs-graph 3.6.0 ParentMap#<K> { |
| 198 | fn fromrust-analyzer cargo vcs-graph 3.6.0 impl#[`ParentMap<K>`][`From<HashMap<K, Vec<K>>>`]from().(map: HashMaprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/HashMap#<K, Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<K>>) -> Selfrust-analyzer cargo vcs-graph 3.6.0 impl#[`ParentMap<K>`][`From<HashMap<K, Vec<K>>>`] { |
| 199 | ParentMaprust-analyzer cargo vcs-graph 3.6.0 ParentMap#( |
| 200 | map.into_iterrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`][IntoIterator]into_iter().() |
| 201 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|(k, v)| (k, Parentsrust-analyzer cargo vcs-graph 3.6.0 Parents#::Knownrust-analyzer cargo vcs-graph 3.6.0 Parents#Known#(v))) |
| 202 | .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<HashMaprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/HashMap#<K, Parentsrust-analyzer cargo vcs-graph 3.6.0 Parents#<K>>>(), |
| 203 | ) |
| 204 | } |
| 205 | } |
| 206 | |
| 207 | impl<K: Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hash# + Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone# + PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq# + Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq#> IntoIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator# for ParentMaprust-analyzer cargo vcs-graph 3.6.0 ParentMap#<K> { |
| 208 | type Itemrust-analyzer cargo vcs-graph 3.6.0 impl#[`ParentMap<K>`][IntoIterator]Item# = (K, Parentsrust-analyzer cargo vcs-graph 3.6.0 Parents#<K>); |
| 209 | type IntoIterrust-analyzer cargo vcs-graph 3.6.0 impl#[`ParentMap<K>`][IntoIterator]IntoIter# = stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::collectionsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/::hash_maprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash_map/::IntoIterrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/IntoIter#<K, Parentsrust-analyzer cargo vcs-graph 3.6.0 Parents#<K>>; |
| 210 | |
| 211 | fn into_iterrust-analyzer cargo vcs-graph 3.6.0 impl#[`ParentMap<K>`][IntoIterator]into_iter().(self) -> Selfrust-analyzer cargo vcs-graph 3.6.0 impl#[`ParentMap<K>`][IntoIterator]::IntoIterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#IntoIter# { |
| 212 | self.0rust-analyzer cargo vcs-graph 3.6.0 ParentMap#0..into_iterrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`][IntoIterator]into_iter().() |
| 213 | } |
| 214 | } |
| 215 | |
| 216 | #[cfg(feature = "pyo3")] |
| 217 | impl<'py, K: pyo3rust-analyzer cargo pyo3 0.28.3 crate/::IntoPyObjectrust-analyzer cargo pyo3 0.28.3 conversion/IntoPyObject#<'py, Errorrust-analyzer cargo pyo3 0.28.3 conversion/IntoPyObject#Error# = pyo3rust-analyzer cargo pyo3 0.28.3 crate/::PyErrrust-analyzer cargo pyo3 0.28.3 err/PyErr#> + Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hash# + Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone# + PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq# + Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq#> |
| 218 | pyo3rust-analyzer cargo pyo3 0.28.3 crate/::IntoPyObjectrust-analyzer cargo pyo3 0.28.3 conversion/IntoPyObject#<'py> for ParentMaprust-analyzer cargo vcs-graph 3.6.0 ParentMap#<K> |
| 219 | { |
| 220 | type Targetrust-analyzer cargo vcs-graph 3.6.0 impl#[`ParentMap<K>`][`IntoPyObject<'py>`]Target# = pyo3rust-analyzer cargo pyo3 0.28.3 crate/::typesrust-analyzer cargo pyo3 0.28.3 types/::PyDictrust-analyzer cargo pyo3 0.28.3 types/dict/PyDict#; |
| 221 | |
| 222 | type Outputrust-analyzer cargo vcs-graph 3.6.0 impl#[`ParentMap<K>`][`IntoPyObject<'py>`]Output# = pyo3rust-analyzer cargo pyo3 0.28.3 crate/::Boundrust-analyzer cargo pyo3 0.28.3 instance/Bound#<'py, Selfrust-analyzer cargo vcs-graph 3.6.0 impl#[`ParentMap<K>`][`IntoPyObject<'py>`]::Targetrust-analyzer cargo pyo3 0.28.3 conversion/IntoPyObject#Target#>; |
| 223 | |
| 224 | type Errorrust-analyzer cargo vcs-graph 3.6.0 impl#[`ParentMap<K>`][`IntoPyObject<'py>`]Error# = pyo3rust-analyzer cargo pyo3 0.28.3 crate/::PyErrrust-analyzer cargo pyo3 0.28.3 err/PyErr#; |
| 225 | |
| 226 | fn into_pyobjectrust-analyzer cargo vcs-graph 3.6.0 impl#[`ParentMap<K>`][`IntoPyObject<'py>`]into_pyobject().(self, py: pyo3rust-analyzer cargo pyo3 0.28.3 crate/::Pythonrust-analyzer cargo pyo3 0.28.3 marker/Python#<'py>) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo vcs-graph 3.6.0 impl#[`ParentMap<K>`][`IntoPyObject<'py>`]::Outputrust-analyzer cargo pyo3 0.28.3 conversion/IntoPyObject#Output#, Selfrust-analyzer cargo vcs-graph 3.6.0 impl#[`ParentMap<K>`][`IntoPyObject<'py>`]::Errorrust-analyzer cargo pyo3 0.28.3 conversion/IntoPyObject#Error#> { |
| 227 | use pyo3rust-analyzer cargo pyo3 0.28.3 crate/::preluderust-analyzer cargo pyo3 0.28.3 prelude/::*; |
| 228 | let dict = pyo3rust-analyzer cargo pyo3 0.28.3 crate/::typesrust-analyzer cargo pyo3 0.28.3 types/::PyDictrust-analyzer cargo pyo3 0.28.3 types/dict/PyDict#::newrust-analyzer cargo pyo3 0.28.3 types/dict/impl#[PyDict]new().(py); |
| 229 | for (k, v) in self.into_iterrust-analyzer cargo vcs-graph 3.6.0 impl#[`ParentMap<K>`][IntoIterator]into_iter().() { |
| 230 | dict.set_itemrust-analyzer cargo pyo3 0.28.3 types/dict/impl#[`Bound<'py, PyDict>`][`PyDictMethods<'py>`]set_item().(k, v)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 231 | } |
| 232 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(dict) |
| 233 | } |
| 234 | } |
| 235 | |
| 236 | #[cfg(feature = "pyo3")] |
| 237 | impl<'py, K> pyo3rust-analyzer cargo pyo3 0.28.3 crate/::FromPyObjectrust-analyzer cargo pyo3 0.28.3 conversion/FromPyObject#<'_, 'py> for ParentMaprust-analyzer cargo vcs-graph 3.6.0 ParentMap#<K> |
| 238 | where |
| 239 | K: for<'a> pyo3rust-analyzer cargo pyo3 0.28.3 crate/::FromPyObjectrust-analyzer cargo pyo3 0.28.3 conversion/FromPyObject#<'a, 'py, Errorrust-analyzer cargo pyo3 0.28.3 conversion/FromPyObject#Error# = pyo3rust-analyzer cargo pyo3 0.28.3 crate/::PyErrrust-analyzer cargo pyo3 0.28.3 err/PyErr#> + Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hash# + Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone# + PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq# + Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq#, |
| 240 | { |
| 241 | type Errorrust-analyzer cargo vcs-graph 3.6.0 impl#[`ParentMap<K>`][`FromPyObject<'_, 'py>`]Error# = pyo3rust-analyzer cargo pyo3 0.28.3 crate/::PyErrrust-analyzer cargo pyo3 0.28.3 err/PyErr#; |
| 242 | |
| 243 | fn extractrust-analyzer cargo vcs-graph 3.6.0 impl#[`ParentMap<K>`][`FromPyObject<'_, 'py>`]extract().(obj: pyo3rust-analyzer cargo pyo3 0.28.3 crate/::Borrowedrust-analyzer cargo pyo3 0.28.3 instance/Borrowed#<'_, 'py, pyo3rust-analyzer cargo pyo3 0.28.3 crate/::PyAnyrust-analyzer cargo pyo3 0.28.3 types/any/PyAny#>) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo vcs-graph 3.6.0 impl#[`ParentMap<K>`][`FromPyObject<'_, 'py>`], Selfrust-analyzer cargo vcs-graph 3.6.0 impl#[`ParentMap<K>`][`FromPyObject<'_, 'py>`]::Errorrust-analyzer cargo pyo3 0.28.3 conversion/FromPyObject#Error#> { |
| 244 | use pyo3rust-analyzer cargo pyo3 0.28.3 crate/::preluderust-analyzer cargo pyo3 0.28.3 prelude/::*; |
| 245 | let dict = obj.castrust-analyzer cargo pyo3 0.28.3 instance/impl#[`Borrowed<'a, 'py, T>`]cast().::<pyo3rust-analyzer cargo pyo3 0.28.3 crate/::typesrust-analyzer cargo pyo3 0.28.3 types/::PyDictrust-analyzer cargo pyo3 0.28.3 types/dict/PyDict#>()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 246 | let mut result = ParentMaprust-analyzer cargo vcs-graph 3.6.0 ParentMap#::newrust-analyzer cargo vcs-graph 3.6.0 impl#[`ParentMap<K>`]new().(); |
| 247 | for (k, v) in dict.iterrust-analyzer cargo pyo3 0.28.3 types/dict/impl#[`Bound<'py, PyDict>`][`PyDictMethods<'py>`]iter().() { |
| 248 | result.insertrust-analyzer cargo vcs-graph 3.6.0 impl#[`ParentMap<K>`]insert().(k.extractrust-analyzer cargo pyo3 0.28.3 types/any/impl#[`Bound<'py, PyAny>`][`PyAnyMethods<'py>`]extract().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()., v.extractrust-analyzer cargo pyo3 0.28.3 types/any/impl#[`Bound<'py, PyAny>`][`PyAnyMethods<'py>`]extract().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().); |
| 249 | } |
| 250 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(result) |
| 251 | } |
| 252 | } |
| 253 | |
| 254 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:)] |
| 255 | pub struct ChildMaprust-analyzer cargo vcs-graph 3.6.0 ChildMap#<K: PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq# + Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq# + Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hash#>(HashMaprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/HashMap#<K, Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<K>>); |
| 256 | |
| 257 | impl<K: Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone# + Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hash# + PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq# + Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq#> Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default# for ChildMaprust-analyzer cargo vcs-graph 3.6.0 ChildMap#<K> { |
| 258 | fn defaultrust-analyzer cargo vcs-graph 3.6.0 impl#[`ChildMap<K>`][Default]default().() -> Selfrust-analyzer cargo vcs-graph 3.6.0 impl#[`ChildMap<K>`][Default] { |
| 259 | Selfrust-analyzer cargo vcs-graph 3.6.0 impl#[`ChildMap<K>`][Default]::newrust-analyzer cargo vcs-graph 3.6.0 impl#[`ChildMap<K>`]new().() |
| 260 | } |
| 261 | } |
| 262 | |
| 263 | impl<K: Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone# + Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hash# + PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq# + Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq#> ChildMaprust-analyzer cargo vcs-graph 3.6.0 ChildMap#<K> { |
| 264 | pub fn newrust-analyzer cargo vcs-graph 3.6.0 impl#[`ChildMap<K>`]new().() -> Selfrust-analyzer cargo vcs-graph 3.6.0 impl#[`ChildMap<K>`] { |
| 265 | ChildMaprust-analyzer cargo vcs-graph 3.6.0 ChildMap#(HashMaprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/HashMap#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V>`]new().()) |
| 266 | } |
| 267 | |
| 268 | #[inline] |
| 269 | pub fn insertrust-analyzer cargo vcs-graph 3.6.0 impl#[`ChildMap<K>`]insert().(&mut self, k: K) { |
| 270 | self.0rust-analyzer cargo vcs-graph 3.6.0 ChildMap#0..entryrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]entry().(k).or_defaultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`Entry<'a, K, V>`]or_default().(); |
| 271 | } |
| 272 | |
| 273 | #[inline] |
| 274 | pub fn drainrust-analyzer cargo vcs-graph 3.6.0 impl#[`ChildMap<K>`]drain().(&mut self) -> impl Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item# = (K, Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<K>)> + '_ { |
| 275 | self.0rust-analyzer cargo vcs-graph 3.6.0 ChildMap#0..drainrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]drain().() |
| 276 | } |
| 277 | |
| 278 | #[inline] |
| 279 | pub fn addrust-analyzer cargo vcs-graph 3.6.0 impl#[`ChildMap<K>`]add().(&mut self, k: K, v: K) { |
| 280 | self.0rust-analyzer cargo vcs-graph 3.6.0 ChildMap#0..entryrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]entry().(k).or_defaultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`Entry<'a, K, V>`]or_default().().pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(v); |
| 281 | } |
| 282 | |
| 283 | #[inline] |
| 284 | pub fn iterrust-analyzer cargo vcs-graph 3.6.0 impl#[`ChildMap<K>`]iter().(&self) -> impl Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item# = (&K, &Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<K>)> { |
| 285 | self.0rust-analyzer cargo vcs-graph 3.6.0 ChildMap#0..iterrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]iter().() |
| 286 | } |
| 287 | |
| 288 | #[inline] |
| 289 | pub fn getrust-analyzer cargo vcs-graph 3.6.0 impl#[`ChildMap<K>`]get().(&self, k: &K) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<K>> { |
| 290 | self.0rust-analyzer cargo vcs-graph 3.6.0 ChildMap#0..getrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]get().(k) |
| 291 | } |
| 292 | |
| 293 | #[inline] |
| 294 | pub fn removerust-analyzer cargo vcs-graph 3.6.0 impl#[`ChildMap<K>`]remove().(&mut self, k: &K) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<K>> { |
| 295 | self.0rust-analyzer cargo vcs-graph 3.6.0 ChildMap#0..removerust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]remove().(k) |
| 296 | } |
| 297 | |
| 298 | #[inline] |
| 299 | pub fn is_emptyrust-analyzer cargo vcs-graph 3.6.0 impl#[`ChildMap<K>`]is_empty().(&self) -> bool { |
| 300 | self.0rust-analyzer cargo vcs-graph 3.6.0 ChildMap#0..is_emptyrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]is_empty().() |
| 301 | } |
| 302 | |
| 303 | #[inline] |
| 304 | pub fn contains_keyrust-analyzer cargo vcs-graph 3.6.0 impl#[`ChildMap<K>`]contains_key().(&self, k: &K) -> bool { |
| 305 | self.0rust-analyzer cargo vcs-graph 3.6.0 ChildMap#0..contains_keyrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]contains_key().(k) |
| 306 | } |
| 307 | } |
| 308 | |
| 309 | impl<K: Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hash# + Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone# + Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq#> stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::opsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/::Indexrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#<&K> for ChildMaprust-analyzer cargo vcs-graph 3.6.0 ChildMap#<K> { |
| 310 | type Outputrust-analyzer cargo vcs-graph 3.6.0 impl#[`ChildMap<K>`][`Index<&K>`]Output# = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<K>; |
| 311 | |
| 312 | fn indexrust-analyzer cargo vcs-graph 3.6.0 impl#[`ChildMap<K>`][`Index<&K>`]index().(&self, index: &K) -> &Selfrust-analyzer cargo vcs-graph 3.6.0 impl#[`ChildMap<K>`][`Index<&K>`]::Outputrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#Output# { |
| 313 | &self.0rust-analyzer cargo vcs-graph 3.6.0 ChildMap#0.[rust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`][`Index<&Q>`]index().index]rust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`][`Index<&Q>`]index(). |
| 314 | } |
| 315 | } |
| 316 | |
| 317 | impl<K: Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hash# + Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone# + Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq#> IntoIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator# for ChildMaprust-analyzer cargo vcs-graph 3.6.0 ChildMap#<K> { |
| 318 | type Itemrust-analyzer cargo vcs-graph 3.6.0 impl#[`ChildMap<K>`][IntoIterator]Item# = (K, Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<K>); |
| 319 | type IntoIterrust-analyzer cargo vcs-graph 3.6.0 impl#[`ChildMap<K>`][IntoIterator]IntoIter# = stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::collectionsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/::hash_maprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash_map/::IntoIterrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/IntoIter#<K, Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<K>>; |
| 320 | |
| 321 | fn into_iterrust-analyzer cargo vcs-graph 3.6.0 impl#[`ChildMap<K>`][IntoIterator]into_iter().(self) -> Selfrust-analyzer cargo vcs-graph 3.6.0 impl#[`ChildMap<K>`][IntoIterator]::IntoIterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#IntoIter# { |
| 322 | self.0rust-analyzer cargo vcs-graph 3.6.0 ChildMap#0..into_iterrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`][IntoIterator]into_iter().() |
| 323 | } |
| 324 | } |
| 325 | |
| 326 | #[cfg(feature = "pyo3")] |
| 327 | impl<'py, K: pyo3rust-analyzer cargo pyo3 0.28.3 crate/::IntoPyObjectrust-analyzer cargo pyo3 0.28.3 conversion/IntoPyObject#<'py> + Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hash# + Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone# + PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq# + Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq#> pyo3rust-analyzer cargo pyo3 0.28.3 crate/::IntoPyObjectrust-analyzer cargo pyo3 0.28.3 conversion/IntoPyObject#<'py> |
| 328 | for ChildMaprust-analyzer cargo vcs-graph 3.6.0 ChildMap#<K> |
| 329 | { |
| 330 | type Targetrust-analyzer cargo vcs-graph 3.6.0 impl#[`ChildMap<K>`][`IntoPyObject<'py>`]Target# = pyo3rust-analyzer cargo pyo3 0.28.3 crate/::typesrust-analyzer cargo pyo3 0.28.3 types/::PyDictrust-analyzer cargo pyo3 0.28.3 types/dict/PyDict#; |
| 331 | |
| 332 | type Outputrust-analyzer cargo vcs-graph 3.6.0 impl#[`ChildMap<K>`][`IntoPyObject<'py>`]Output# = pyo3rust-analyzer cargo pyo3 0.28.3 crate/::Boundrust-analyzer cargo pyo3 0.28.3 instance/Bound#<'py, Selfrust-analyzer cargo vcs-graph 3.6.0 impl#[`ChildMap<K>`][`IntoPyObject<'py>`]::Targetrust-analyzer cargo pyo3 0.28.3 conversion/IntoPyObject#Target#>; |
| 333 | |
| 334 | type Errorrust-analyzer cargo vcs-graph 3.6.0 impl#[`ChildMap<K>`][`IntoPyObject<'py>`]Error# = pyo3rust-analyzer cargo pyo3 0.28.3 crate/::PyErrrust-analyzer cargo pyo3 0.28.3 err/PyErr#; |
| 335 | |
| 336 | fn into_pyobjectrust-analyzer cargo vcs-graph 3.6.0 impl#[`ChildMap<K>`][`IntoPyObject<'py>`]into_pyobject().(self, py: pyo3rust-analyzer cargo pyo3 0.28.3 crate/::Pythonrust-analyzer cargo pyo3 0.28.3 marker/Python#<'py>) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo vcs-graph 3.6.0 impl#[`ChildMap<K>`][`IntoPyObject<'py>`]::Outputrust-analyzer cargo pyo3 0.28.3 conversion/IntoPyObject#Output#, Selfrust-analyzer cargo vcs-graph 3.6.0 impl#[`ChildMap<K>`][`IntoPyObject<'py>`]::Errorrust-analyzer cargo pyo3 0.28.3 conversion/IntoPyObject#Error#> { |
| 337 | use pyo3rust-analyzer cargo pyo3 0.28.3 crate/::preluderust-analyzer cargo pyo3 0.28.3 prelude/::*; |
| 338 | let dict = pyo3rust-analyzer cargo pyo3 0.28.3 crate/::typesrust-analyzer cargo pyo3 0.28.3 types/::PyDictrust-analyzer cargo pyo3 0.28.3 types/dict/PyDict#::newrust-analyzer cargo pyo3 0.28.3 types/dict/impl#[PyDict]new().(py); |
| 339 | for (k, v) in self.into_iterrust-analyzer cargo vcs-graph 3.6.0 impl#[`ChildMap<K>`][IntoIterator]into_iter().() { |
| 340 | dict.set_itemrust-analyzer cargo pyo3 0.28.3 types/dict/impl#[`Bound<'py, PyDict>`][`PyDictMethods<'py>`]set_item().(k, v)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 341 | } |
| 342 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(dict) |
| 343 | } |
| 344 | } |
| 345 | |
| 346 | impl<K: Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hash# + Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone# + Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq#> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<HashMaprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/HashMap#<K, Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<K>>> for ChildMaprust-analyzer cargo vcs-graph 3.6.0 ChildMap#<K> { |
| 347 | fn fromrust-analyzer cargo vcs-graph 3.6.0 impl#[`ChildMap<K>`][`From<HashMap<K, Vec<K>>>`]from().(map: HashMaprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/HashMap#<K, Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<K>>) -> Selfrust-analyzer cargo vcs-graph 3.6.0 impl#[`ChildMap<K>`][`From<HashMap<K, Vec<K>>>`] { |
| 348 | ChildMaprust-analyzer cargo vcs-graph 3.6.0 ChildMap#(map) |
| 349 | } |
| 350 | } |
| 351 | |
| 352 | /// Create a child map from a parent map. |
| 353 | pub fn invert_parent_maprust-analyzer cargo vcs-graph 3.6.0 invert_parent_map().<K: Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hash# + Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq# + Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#>(parent_map: &ParentMaprust-analyzer cargo vcs-graph 3.6.0 ParentMap#<K>) -> ChildMaprust-analyzer cargo vcs-graph 3.6.0 ChildMap#<K> { |
| 354 | let mut child_map = ChildMaprust-analyzer cargo vcs-graph 3.6.0 ChildMap#::newrust-analyzer cargo vcs-graph 3.6.0 impl#[`ChildMap<K>`]new().(); |
| 355 | for (child, parents) in parent_map.iterrust-analyzer cargo vcs-graph 3.6.0 impl#[`ParentMap<K>`]iter().() { |
| 356 | if parents.is_ghostrust-analyzer cargo vcs-graph 3.6.0 impl#[`Parents<K>`]is_ghost().() { |
| 357 | continue; |
| 358 | } |
| 359 | for p in parents.as_slicerust-analyzer cargo vcs-graph 3.6.0 impl#[`Parents<K>`]as_slice().() { |
| 360 | child_map.addrust-analyzer cargo vcs-graph 3.6.0 impl#[`ChildMap<K>`]add().(p.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().(), child.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().()); |
| 361 | } |
| 362 | } |
| 363 | child_map |
| 364 | } |
| 365 | |
| 366 | impl<K> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<ParentMaprust-analyzer cargo vcs-graph 3.6.0 ParentMap#<K>> for ChildMaprust-analyzer cargo vcs-graph 3.6.0 ChildMap#<K> |
| 367 | where |
| 368 | K: Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hash# + Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq# + Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#, |
| 369 | { |
| 370 | fn fromrust-analyzer cargo vcs-graph 3.6.0 impl#[`ChildMap<K>`][`From<ParentMap<K>>`]from().(parent_map: ParentMaprust-analyzer cargo vcs-graph 3.6.0 ParentMap#<K>) -> Selfrust-analyzer cargo vcs-graph 3.6.0 impl#[`ChildMap<K>`][`From<ParentMap<K>>`] { |
| 371 | invert_parent_maprust-analyzer cargo vcs-graph 3.6.0 invert_parent_map().(&parent_map) |
| 372 | } |
| 373 | } |
| 374 | |
| 375 | #[cfg(test)] |
| 376 | mod invert_parent_map_testsrust-analyzer cargo vcs-graph 3.6.0 invert_parent_map_tests/ { |
| 377 | use superrust-analyzer cargo vcs-graph 3.6.0 crate/::*; |
| 378 | use maplitrust-analyzer cargo maplit 1.0.2 crate/::hashmaprust-analyzer cargo maplit 1.0.2 hashmap!; |
| 379 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 380 | fn test_invertrust-analyzer cargo vcs-graph 3.6.0 invert_parent_map_tests/test_invert().() { |
| 381 | let result = superrust-analyzer cargo vcs-graph 3.6.0 crate/::invert_parent_maprust-analyzer cargo vcs-graph 3.6.0 invert_parent_map().(&ParentMaprust-analyzer cargo vcs-graph 3.6.0 ParentMap#::fromrust-analyzer cargo vcs-graph 3.6.0 impl#[`ParentMap<K>`][`From<HashMap<K, Vec<K>>>`]from().(hashmaprust-analyzer cargo maplit 1.0.2 hashmap!! { |
| 382 | 2 => vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![1], |
| 383 | 3 => vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![1, 2], |
| 384 | })); |
| 385 | |
| 386 | // Check node 1's children (order doesn't matter) |
| 387 | let mut node1_children = result.getrust-analyzer cargo vcs-graph 3.6.0 impl#[`ChildMap<K>`]get().(&1).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][Clone]clone().(); |
| 388 | node1_children.sortrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/impl#[`[T]`]sort().(); |
| 389 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![2, 3], node1_children); |
| 390 | |
| 391 | // Check node 2's children |
| 392 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![3], *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().result.getrust-analyzer cargo vcs-graph 3.6.0 impl#[`ChildMap<K>`]get().(&2).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().()); |
| 393 | |
| 394 | // Node 3 should have no children (may not be in the map) |
| 395 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(result.getrust-analyzer cargo vcs-graph 3.6.0 impl#[`ChildMap<K>`]get().(&3).is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().() || result.getrust-analyzer cargo vcs-graph 3.6.0 impl#[`ChildMap<K>`]get().(&3).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().()); |
| 396 | } |
| 397 | |
| 398 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 399 | fn test_ghostrust-analyzer cargo vcs-graph 3.6.0 invert_parent_map_tests/test_ghost().() { |
| 400 | let result = superrust-analyzer cargo vcs-graph 3.6.0 crate/::invert_parent_maprust-analyzer cargo vcs-graph 3.6.0 invert_parent_map().(&ParentMaprust-analyzer cargo vcs-graph 3.6.0 ParentMap#::fromrust-analyzer cargo vcs-graph 3.6.0 impl#[`ParentMap<K>`][`From<HashMap<K, Vec<K>>>`]from().(hashmaprust-analyzer cargo maplit 1.0.2 hashmap!! { |
| 401 | 2 => vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![1], |
| 402 | 3 => vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![1, 2], |
| 403 | })); |
| 404 | |
| 405 | // Check node 1's children (order doesn't matter) |
| 406 | let mut node1_children = result.getrust-analyzer cargo vcs-graph 3.6.0 impl#[`ChildMap<K>`]get().(&1).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][Clone]clone().(); |
| 407 | node1_children.sortrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/impl#[`[T]`]sort().(); |
| 408 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![2, 3], node1_children); |
| 409 | |
| 410 | // Check node 2's children |
| 411 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![3], *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().result.getrust-analyzer cargo vcs-graph 3.6.0 impl#[`ChildMap<K>`]get().(&2).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().()); |
| 412 | } |
| 413 | } |
| 414 | |
| 415 | /// Collapse regions of the graph that are 'linear'. |
| 416 | /// |
| 417 | /// For example:: |
| 418 | /// |
| 419 | /// A:[B], B:[C] |
| 420 | /// |
| 421 | /// can be collapsed by removing B and getting:: |
| 422 | /// |
| 423 | /// A:[C] |
| 424 | /// |
| 425 | /// Args: |
| 426 | /// parent_map: A dictionary mapping children to their parents |
| 427 | /// Returns: Another dictionary with 'linear' chains collapsed |
| 428 | pub fn collapse_linear_regionsrust-analyzer cargo vcs-graph 3.6.0 collapse_linear_regions().<K: Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hash# + Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq# + Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#>(parent_map: &ParentMaprust-analyzer cargo vcs-graph 3.6.0 ParentMap#<K>) -> ParentMaprust-analyzer cargo vcs-graph 3.6.0 ParentMap#<K> { |
| 429 | // Note: this isn't a strictly minimal collapse. For example: |
| 430 | // A |
| 431 | // / \ |
| 432 | // B C |
| 433 | // \ / |
| 434 | // D |
| 435 | // | |
| 436 | // E |
| 437 | // Will not have 'D' removed, even though 'E' could fit. Also: |
| 438 | // A |
| 439 | // | A |
| 440 | // B => | |
| 441 | // | C |
| 442 | // C |
| 443 | // A and C are both kept because they are edges of the graph. We *could* get |
| 444 | // rid of A if we wanted. |
| 445 | // A |
| 446 | // / \ |
| 447 | // B C |
| 448 | // | | |
| 449 | // D E |
| 450 | // \ / |
| 451 | // F |
| 452 | // Will not have any nodes removed, even though you do have an |
| 453 | // 'uninteresting' linear D->B and E->C |
| 454 | let mut children: HashMaprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/HashMap#<K, Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<K>> = HashMaprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/HashMap#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V>`]new().(); |
| 455 | for (child, parents) in parent_map.iterrust-analyzer cargo vcs-graph 3.6.0 impl#[`ParentMap<K>`]iter().() { |
| 456 | children.entryrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]entry().(child.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().()).or_defaultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`Entry<'a, K, V>`]or_default().(); |
| 457 | for p in parents.as_slicerust-analyzer cargo vcs-graph 3.6.0 impl#[`Parents<K>`]as_slice().() { |
| 458 | children.entryrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]entry().(p.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().()).or_defaultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`Entry<'a, K, V>`]or_default().().pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(child.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().()); |
| 459 | } |
| 460 | } |
| 461 | |
| 462 | let mut removed = HashSetrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/HashSet#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T>`]new().(); |
| 463 | let mut result: ParentMaprust-analyzer cargo vcs-graph 3.6.0 ParentMap#<K> = parent_map.clonerust-analyzer cargo vcs-graph 3.6.0 impl#[`ParentMap<K>`][Clone]clone().(); |
| 464 | for node in parent_map.keysrust-analyzer cargo vcs-graph 3.6.0 impl#[`ParentMap<K>`]keys().() { |
| 465 | let parents = result.getrust-analyzer cargo vcs-graph 3.6.0 impl#[`ParentMap<K>`]get().(node).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().as_slicerust-analyzer cargo vcs-graph 3.6.0 impl#[`Parents<K>`]as_slice().(); |
| 466 | if parents.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne().1 { |
| 467 | continue; |
| 468 | } |
| 469 | let parent_children = children.getrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]get().(&parents[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 470 | if parent_children.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne().1 { |
| 471 | // This is not the only child |
| 472 | continue; |
| 473 | } |
| 474 | let node_children = children.getrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]get().(node).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 475 | if node_children.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne().1 { |
| 476 | continue; |
| 477 | } |
| 478 | let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(child_parents) = result.getrust-analyzer cargo vcs-graph 3.6.0 impl#[`ParentMap<K>`]get().(&node_children[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().) else { |
| 479 | continue; |
| 480 | }; |
| 481 | if child_parents.as_slicerust-analyzer cargo vcs-graph 3.6.0 impl#[`Parents<K>`]as_slice().().lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne().1 { |
| 482 | // This is not its only parent |
| 483 | continue; |
| 484 | } |
| 485 | // The child of this node only points at it, and the parent only has |
| 486 | // this as a child. Remove this node and splice around it. |
| 487 | let parents_owned = parents.to_vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/impl#[`[T]`]to_vec().(); |
| 488 | let node_children_owned = node_children.clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][Clone]clone().(); |
| 489 | result.removerust-analyzer cargo vcs-graph 3.6.0 impl#[`ParentMap<K>`]remove().(node); |
| 490 | result.insertrust-analyzer cargo vcs-graph 3.6.0 impl#[`ParentMap<K>`]insert().( |
| 491 | node_children_owned[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()..clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().(), |
| 492 | Parentsrust-analyzer cargo vcs-graph 3.6.0 Parents#::Knownrust-analyzer cargo vcs-graph 3.6.0 Parents#Known#(parents_owned.clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][Clone]clone().()), |
| 493 | ); |
| 494 | children.insertrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]insert().(parents_owned[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()..clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().(), node_children_owned); |
| 495 | children.removerust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]remove().(node); |
| 496 | removed.insertrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]insert().(node); |
| 497 | } |
| 498 | |
| 499 | result |
| 500 | } |
| 501 | |
| 502 | pub mod tsortrust-analyzer cargo vcs-graph 3.6.0 tsort/; |
| 503 | |
| 504 | #[cfg(test)] |
| 505 | mod testrust-analyzer cargo vcs-graph 3.6.0 test/; |
| 506 | |
| 507 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:)] |
| 508 | pub struct RevnoVecrust-analyzer cargo vcs-graph 3.6.0 RevnoVec#(Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<usize>); |
| 509 | |
| 510 | impl RevnoVecrust-analyzer cargo vcs-graph 3.6.0 RevnoVec# { |
| 511 | pub fn newrust-analyzer cargo vcs-graph 3.6.0 impl#[RevnoVec]new().() -> Selfrust-analyzer cargo vcs-graph 3.6.0 impl#[RevnoVec] { |
| 512 | RevnoVecrust-analyzer cargo vcs-graph 3.6.0 RevnoVec#(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![]) |
| 513 | } |
| 514 | |
| 515 | pub fn bump_lastrust-analyzer cargo vcs-graph 3.6.0 impl#[RevnoVec]bump_last().(&self) -> Selfrust-analyzer cargo vcs-graph 3.6.0 impl#[RevnoVec] { |
| 516 | let mut ret = self.clonerust-analyzer cargo vcs-graph 3.6.0 impl#[RevnoVec][Clone]clone().(); |
| 517 | *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().ret.0rust-analyzer cargo vcs-graph 3.6.0 RevnoVec#0..last_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]last_mut().().expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]expect().("bump_last on empty RevnoVec") rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().1; |
| 518 | ret |
| 519 | } |
| 520 | |
| 521 | pub fn new_branchrust-analyzer cargo vcs-graph 3.6.0 impl#[RevnoVec]new_branch().(&self, branch_count: usize) -> Selfrust-analyzer cargo vcs-graph 3.6.0 impl#[RevnoVec] { |
| 522 | RevnoVecrust-analyzer cargo vcs-graph 3.6.0 RevnoVec#::fromrust-analyzer cargo vcs-graph 3.6.0 impl#[RevnoVec][`From<Vec<usize>>`]from().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![self[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()., branch_count, 1]) |
| 523 | } |
| 524 | } |
| 525 | |
| 526 | impl Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default# for RevnoVecrust-analyzer cargo vcs-graph 3.6.0 RevnoVec# { |
| 527 | fn defaultrust-analyzer cargo vcs-graph 3.6.0 impl#[RevnoVec][Default]default().() -> Selfrust-analyzer cargo vcs-graph 3.6.0 impl#[RevnoVec][Default] { |
| 528 | Selfrust-analyzer cargo vcs-graph 3.6.0 impl#[RevnoVec][Default]::newrust-analyzer cargo vcs-graph 3.6.0 impl#[RevnoVec]new().() |
| 529 | } |
| 530 | } |
| 531 | |
| 532 | impl IntoIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator# for RevnoVecrust-analyzer cargo vcs-graph 3.6.0 RevnoVec# { |
| 533 | type Itemrust-analyzer cargo vcs-graph 3.6.0 impl#[RevnoVec][IntoIterator]Item# = usize; |
| 534 | type IntoIterrust-analyzer cargo vcs-graph 3.6.0 impl#[RevnoVec][IntoIterator]IntoIter# = stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/::IntoIterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/into_iter/IntoIter#<usize>; |
| 535 | |
| 536 | fn into_iterrust-analyzer cargo vcs-graph 3.6.0 impl#[RevnoVec][IntoIterator]into_iter().(self) -> Selfrust-analyzer cargo vcs-graph 3.6.0 impl#[RevnoVec][IntoIterator]::IntoIterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#IntoIter# { |
| 537 | self.0rust-analyzer cargo vcs-graph 3.6.0 RevnoVec#0..into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().() |
| 538 | } |
| 539 | } |
| 540 | |
| 541 | impl stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::opsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/::Indexrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#<usize> for RevnoVecrust-analyzer cargo vcs-graph 3.6.0 RevnoVec# { |
| 542 | type Outputrust-analyzer cargo vcs-graph 3.6.0 impl#[RevnoVec][`Index<usize>`]Output# = usize; |
| 543 | |
| 544 | fn indexrust-analyzer cargo vcs-graph 3.6.0 impl#[RevnoVec][`Index<usize>`]index().(&self, index: usize) -> &Selfrust-analyzer cargo vcs-graph 3.6.0 impl#[RevnoVec][`Index<usize>`]::Outputrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#Output# { |
| 545 | &self.0rust-analyzer cargo vcs-graph 3.6.0 RevnoVec#0.[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().index]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index(). |
| 546 | } |
| 547 | } |
| 548 | |
| 549 | impl stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::opsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/::IndexMutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#<usize> for RevnoVecrust-analyzer cargo vcs-graph 3.6.0 RevnoVec# { |
| 550 | fn index_mutrust-analyzer cargo vcs-graph 3.6.0 impl#[RevnoVec][`IndexMut<usize>`]index_mut().(&mut self, index: usize) -> &mut Selfrust-analyzer cargo vcs-graph 3.6.0 impl#[RevnoVec][`IndexMut<usize>`]::Outputrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#Output# { |
| 551 | &mut self.0rust-analyzer cargo vcs-graph 3.6.0 RevnoVec#0.[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`IndexMut<I>`]index_mut().index]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`IndexMut<I>`]index_mut(). |
| 552 | } |
| 553 | } |
| 554 | |
| 555 | impl stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug# for RevnoVecrust-analyzer cargo vcs-graph 3.6.0 RevnoVec# { |
| 556 | fn fmtrust-analyzer cargo vcs-graph 3.6.0 impl#[RevnoVec][Debug]fmt().(&self, f: &mut stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#) -> stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# { |
| 557 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "RevnoVec({:?})", self.0rust-analyzer cargo vcs-graph 3.6.0 RevnoVec#0.) |
| 558 | } |
| 559 | } |
| 560 | |
| 561 | impl stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display# for RevnoVecrust-analyzer cargo vcs-graph 3.6.0 RevnoVec# { |
| 562 | fn fmtrust-analyzer cargo vcs-graph 3.6.0 impl#[RevnoVec][Display]fmt().(&self, f: &mut stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#) -> stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# { |
| 563 | let mut first = true; |
| 564 | for r in self.0rust-analyzer cargo vcs-graph 3.6.0 RevnoVec#0..iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().() { |
| 565 | if first { |
| 566 | first = false; |
| 567 | } else { |
| 568 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, ".")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 569 | } |
| 570 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "{}", r)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 571 | } |
| 572 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 573 | } |
| 574 | } |
| 575 | |
| 576 | impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<usize>> for RevnoVecrust-analyzer cargo vcs-graph 3.6.0 RevnoVec# { |
| 577 | fn fromrust-analyzer cargo vcs-graph 3.6.0 impl#[RevnoVec][`From<Vec<usize>>`]from().(v: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<usize>) -> Selfrust-analyzer cargo vcs-graph 3.6.0 impl#[RevnoVec][`From<Vec<usize>>`] { |
| 578 | RevnoVecrust-analyzer cargo vcs-graph 3.6.0 RevnoVec#(v) |
| 579 | } |
| 580 | } |
| 581 | |
| 582 | impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<usize> for RevnoVecrust-analyzer cargo vcs-graph 3.6.0 RevnoVec# { |
| 583 | fn fromrust-analyzer cargo vcs-graph 3.6.0 impl#[RevnoVec][`From<usize>`]from().(v: usize) -> Selfrust-analyzer cargo vcs-graph 3.6.0 impl#[RevnoVec][`From<usize>`] { |
| 584 | RevnoVecrust-analyzer cargo vcs-graph 3.6.0 RevnoVec#(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![v]) |
| 585 | } |
| 586 | } |
| 587 | |
| 588 | #[cfg(feature = "pyo3")] |
| 589 | impl<'py> pyo3rust-analyzer cargo pyo3 0.28.3 crate/::IntoPyObjectrust-analyzer cargo pyo3 0.28.3 conversion/IntoPyObject#<'py> for RevnoVecrust-analyzer cargo vcs-graph 3.6.0 RevnoVec# { |
| 590 | type Targetrust-analyzer cargo vcs-graph 3.6.0 impl#[RevnoVec][`IntoPyObject<'py>`]Target# = pyo3rust-analyzer cargo pyo3 0.28.3 crate/::typesrust-analyzer cargo pyo3 0.28.3 types/::PyTuplerust-analyzer cargo pyo3 0.28.3 types/tuple/PyTuple#; |
| 591 | |
| 592 | type Outputrust-analyzer cargo vcs-graph 3.6.0 impl#[RevnoVec][`IntoPyObject<'py>`]Output# = pyo3rust-analyzer cargo pyo3 0.28.3 crate/::Boundrust-analyzer cargo pyo3 0.28.3 instance/Bound#<'py, Selfrust-analyzer cargo vcs-graph 3.6.0 impl#[RevnoVec][`IntoPyObject<'py>`]::Targetrust-analyzer cargo pyo3 0.28.3 conversion/IntoPyObject#Target#>; |
| 593 | |
| 594 | type Errorrust-analyzer cargo vcs-graph 3.6.0 impl#[RevnoVec][`IntoPyObject<'py>`]Error# = pyo3rust-analyzer cargo pyo3 0.28.3 crate/::PyErrrust-analyzer cargo pyo3 0.28.3 err/PyErr#; |
| 595 | |
| 596 | fn into_pyobjectrust-analyzer cargo vcs-graph 3.6.0 impl#[RevnoVec][`IntoPyObject<'py>`]into_pyobject().(self, py: pyo3rust-analyzer cargo pyo3 0.28.3 crate/::Pythonrust-analyzer cargo pyo3 0.28.3 marker/Python#<'py>) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo vcs-graph 3.6.0 impl#[RevnoVec][`IntoPyObject<'py>`]::Outputrust-analyzer cargo pyo3 0.28.3 conversion/IntoPyObject#Output#, Selfrust-analyzer cargo vcs-graph 3.6.0 impl#[RevnoVec][`IntoPyObject<'py>`]::Errorrust-analyzer cargo pyo3 0.28.3 conversion/IntoPyObject#Error#> { |
| 597 | pyo3rust-analyzer cargo pyo3 0.28.3 crate/::typesrust-analyzer cargo pyo3 0.28.3 types/::PyTuplerust-analyzer cargo pyo3 0.28.3 types/tuple/PyTuple#::newrust-analyzer cargo pyo3 0.28.3 types/tuple/impl#[PyTuple]new().(py, self.0rust-analyzer cargo vcs-graph 3.6.0 RevnoVec#0..iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().()) |
| 598 | } |
| 599 | } |
| 600 | |
| 601 | #[cfg(feature = "pyo3")] |
| 602 | impl<'py> pyo3rust-analyzer cargo pyo3 0.28.3 crate/::FromPyObjectrust-analyzer cargo pyo3 0.28.3 conversion/FromPyObject#<'_, 'py> for RevnoVecrust-analyzer cargo vcs-graph 3.6.0 RevnoVec# { |
| 603 | type Errorrust-analyzer cargo vcs-graph 3.6.0 impl#[RevnoVec][`FromPyObject<'_, 'py>`]Error# = pyo3rust-analyzer cargo pyo3 0.28.3 crate/::PyErrrust-analyzer cargo pyo3 0.28.3 err/PyErr#; |
| 604 | |
| 605 | fn extractrust-analyzer cargo vcs-graph 3.6.0 impl#[RevnoVec][`FromPyObject<'_, 'py>`]extract().(obj: pyo3rust-analyzer cargo pyo3 0.28.3 crate/::Borrowedrust-analyzer cargo pyo3 0.28.3 instance/Borrowed#<'_, 'py, pyo3rust-analyzer cargo pyo3 0.28.3 crate/::PyAnyrust-analyzer cargo pyo3 0.28.3 types/any/PyAny#>) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo vcs-graph 3.6.0 impl#[RevnoVec][`FromPyObject<'_, 'py>`], Selfrust-analyzer cargo vcs-graph 3.6.0 impl#[RevnoVec][`FromPyObject<'_, 'py>`]::Errorrust-analyzer cargo pyo3 0.28.3 conversion/FromPyObject#Error#> { |
| 606 | use pyo3rust-analyzer cargo pyo3 0.28.3 crate/::preluderust-analyzer cargo pyo3 0.28.3 prelude/::*; |
| 607 | let tuple = obj.castrust-analyzer cargo pyo3 0.28.3 instance/impl#[`Borrowed<'a, 'py, T>`]cast().::<pyo3rust-analyzer cargo pyo3 0.28.3 crate/::typesrust-analyzer cargo pyo3 0.28.3 types/::PyTuplerust-analyzer cargo pyo3 0.28.3 types/tuple/PyTuple#>()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 608 | let mut ret = RevnoVecrust-analyzer cargo vcs-graph 3.6.0 RevnoVec#::newrust-analyzer cargo vcs-graph 3.6.0 impl#[RevnoVec]new().(); |
| 609 | for r in tuple.iterrust-analyzer cargo pyo3 0.28.3 types/tuple/impl#[`Bound<'py, PyTuple>`][`PyTupleMethods<'py>`]iter().() { |
| 610 | ret.0rust-analyzer cargo vcs-graph 3.6.0 RevnoVec#0..pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(r.extractrust-analyzer cargo pyo3 0.28.3 types/any/impl#[`Bound<'py, PyAny>`][`PyAnyMethods<'py>`]extract().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().); |
| 611 | } |
| 612 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(ret) |
| 613 | } |
| 614 | } |
| 615 | |
| 616 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)] |
| 617 | pub enum Errorrust-analyzer cargo vcs-graph 3.6.0 Error#<K> { |
| 618 | Cyclerust-analyzer cargo vcs-graph 3.6.0 Error#Cycle#(Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<K>), |
| 619 | ParentMismatchrust-analyzer cargo vcs-graph 3.6.0 Error#ParentMismatch# { |
| 620 | keyrust-analyzer cargo vcs-graph 3.6.0 Error#ParentMismatch#key.: K, |
| 621 | expectedrust-analyzer cargo vcs-graph 3.6.0 Error#ParentMismatch#expected.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<K>, |
| 622 | actualrust-analyzer cargo vcs-graph 3.6.0 Error#ParentMismatch#actual.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<K>, |
| 623 | }, |
| 624 | } |
| 625 | |
| 626 | impl<K: stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display#> stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display# for Errorrust-analyzer cargo vcs-graph 3.6.0 Error#<K> { |
| 627 | fn fmtrust-analyzer cargo vcs-graph 3.6.0 impl#[`Error<K>`][Display]fmt().(&self, f: &mut stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#) -> stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# { |
| 628 | match self { |
| 629 | Errorrust-analyzer cargo vcs-graph 3.6.0 Error#::Cyclerust-analyzer cargo vcs-graph 3.6.0 Error#Cycle#(cycle) => { |
| 630 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "Cycle: ")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 631 | let mut first = true; |
| 632 | for c in cycle.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().() { |
| 633 | if first { |
| 634 | first = false; |
| 635 | } else { |
| 636 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, " -> ")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 637 | } |
| 638 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "{}", c)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 639 | } |
| 640 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 641 | } |
| 642 | Errorrust-analyzer cargo vcs-graph 3.6.0 Error#::ParentMismatchrust-analyzer cargo vcs-graph 3.6.0 Error#ParentMismatch# { |
| 643 | keyrust-analyzer cargo vcs-graph 3.6.0 Error#ParentMismatch#key., |
| 644 | expectedrust-analyzer cargo vcs-graph 3.6.0 Error#ParentMismatch#expected., |
| 645 | actualrust-analyzer cargo vcs-graph 3.6.0 Error#ParentMismatch#actual., |
| 646 | } => { |
| 647 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "Parent mismatch for {}: ", key)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 648 | let mut first = true; |
| 649 | for e in expected.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().() { |
| 650 | if first { |
| 651 | first = false; |
| 652 | } else { |
| 653 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, ", ")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 654 | } |
| 655 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "{}", e)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 656 | } |
| 657 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, " != ")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 658 | let mut first = true; |
| 659 | for a in actual.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().() { |
| 660 | if first { |
| 661 | first = false; |
| 662 | } else { |
| 663 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, ", ")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 664 | } |
| 665 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "{}", a)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 666 | } |
| 667 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 668 | } |
| 669 | } |
| 670 | } |
| 671 | } |
| 672 | |
| 673 | impl<K: stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug# + stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display#> stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std error/::Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# for Errorrust-analyzer cargo vcs-graph 3.6.0 Error#<K> {} |