Debian Codegraph @

src/set/mutable.rs

raw symbols SCIP
1 use superrust-analyzer cargo ordermap 1.2.0 set/::{Equivalentrust-analyzer cargo equivalent 1.0.2 Equivalent#, OrderSetrust-analyzer cargo ordermap 1.2.0 set/OrderSet#};
2 use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/::{BuildHasherrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/BuildHasher#, Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hash#};
3 use indexmaprust-analyzer cargo indexmap 2.14.0 crate/::setrust-analyzer cargo indexmap 2.14.0 set/::MutableValuesrust-analyzer cargo indexmap 2.14.0 set/mutable/MutableValues# as _;
4
5 /// Opt-in mutable access to [`OrderSet`] values.
6 ///
7 /// These methods expose `&mut T`, mutable references to the value as it is stored
8 /// in the set.
9 /// You are allowed to modify the values in the set **if the modification
10 /// does not change the value's hash and equality**.
11 ///
12 /// If values are modified erroneously, you can no longer look them up.
13 /// This is sound (memory safe) but a logical error hazard (just like
14 /// implementing `PartialEq`, `Eq`, or `Hash` incorrectly would be).
15 ///
16 /// `use` this trait to enable its methods for `OrderSet`.
17 ///
18 /// This trait is sealed and cannot be implemented for types outside this crate.
19 #[expect(private_bounds)]
20 pub trait MutableValuesrust-analyzer cargo ordermap 1.2.0 set/mutable/MutableValues#: Sealedrust-analyzer cargo ordermap 1.2.0 set/mutable/Sealed# {
21 type Valuerust-analyzer cargo ordermap 1.2.0 set/mutable/MutableValues#Value#;
22
23 /// Return item index and mutable reference to the value
24 ///
25 /// Computes in **O(1)** time (average).
26 fn get_full_mut2rust-analyzer cargo ordermap 1.2.0 set/mutable/MutableValues#get_full_mut2().<Q>(&mut self, value: &Q) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<(usize, &mut Self::Valuerust-analyzer cargo ordermap 1.2.0 set/mutable/MutableValues#Value#)>
27 where
28 Q: ?Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized# + Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hash# + Equivalentrust-analyzer cargo equivalent 1.0.2 Equivalent#<Self::Valuerust-analyzer cargo ordermap 1.2.0 set/mutable/MutableValues#Value#>;
29
30 /// Return mutable reference to the value at an index.
31 ///
32 /// Valid indices are `0 <= index < self.len()`.
33 ///
34 /// Computes in **O(1)** time.
35 fn get_index_mut2rust-analyzer cargo ordermap 1.2.0 set/mutable/MutableValues#get_index_mut2().(&mut self, index: usize) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&mut Self::Valuerust-analyzer cargo ordermap 1.2.0 set/mutable/MutableValues#Value#>;
36
37 /// Scan through each value in the set and keep those where the
38 /// closure `keep` returns `true`.
39 ///
40 /// The values are visited in order, and remaining values keep their order.
41 ///
42 /// Computes in **O(n)** time (average).
43 fn retain2rust-analyzer cargo ordermap 1.2.0 set/mutable/MutableValues#retain2().<F>(&mut self, keep: F)
44 where
45 F: FnMutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/function/FnMut#(&mut Self::Valuerust-analyzer cargo ordermap 1.2.0 set/mutable/MutableValues#Value#) -> bool;
46 }
47
48 /// Opt-in mutable access to [`OrderSet`] values.
49 ///
50 /// See [`MutableValues`] for more information.
51 impl<T, S> MutableValuesrust-analyzer cargo ordermap 1.2.0 set/mutable/MutableValues# for OrderSetrust-analyzer cargo ordermap 1.2.0 set/OrderSet#<T, S>
52 where
53 S: BuildHasherrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/BuildHasher#,
54 {
55 type Valuerust-analyzer cargo ordermap 1.2.0 set/mutable/impl#[`OrderSet<T, S>`][MutableValues]Value# = T;
56
57 fn get_full_mut2rust-analyzer cargo ordermap 1.2.0 set/mutable/impl#[`OrderSet<T, S>`][MutableValues]get_full_mut2().<Q>(&mut self, value: &Q) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<(usize, &mut T)>
58 where
59 Q: ?Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized# + Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hash# + Equivalentrust-analyzer cargo equivalent 1.0.2 Equivalent#<T>,
60 {
61 self.innerrust-analyzer cargo ordermap 1.2.0 set/OrderSet#inner..get_full_mut2rust-analyzer cargo indexmap 2.14.0 set/mutable/impl#[`IndexSet<T, S>`][MutableValues]get_full_mut2().(value)
62 }
63
64 fn get_index_mut2rust-analyzer cargo ordermap 1.2.0 set/mutable/impl#[`OrderSet<T, S>`][MutableValues]get_index_mut2().(&mut self, index: usize) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&mut T> {
65 self.innerrust-analyzer cargo ordermap 1.2.0 set/OrderSet#inner..get_index_mut2rust-analyzer cargo indexmap 2.14.0 set/mutable/impl#[`IndexSet<T, S>`][MutableValues]get_index_mut2().(index)
66 }
67
68 fn retain2rust-analyzer cargo ordermap 1.2.0 set/mutable/impl#[`OrderSet<T, S>`][MutableValues]retain2().<F>(&mut self, keep: F)
69 where
70 F: FnMutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/function/FnMut#(&mut T) -> bool,
71 {
72 self.innerrust-analyzer cargo ordermap 1.2.0 set/OrderSet#inner..retain2rust-analyzer cargo indexmap 2.14.0 set/mutable/impl#[`IndexSet<T, S>`][MutableValues]retain2().(keep);
73 }
74 }
75
76 trait Sealedrust-analyzer cargo ordermap 1.2.0 set/mutable/Sealed# {}
77
78 impl<T, S> Sealedrust-analyzer cargo ordermap 1.2.0 set/mutable/Sealed# for OrderSetrust-analyzer cargo ordermap 1.2.0 set/OrderSet#<T, S> {}