Struct immutable_chunkmap::map::Map
source · Expand description
This Map uses a similar strategy to BTreeMap to ensure cache efficient performance on modern hardware while still providing log(N) get, insert, and remove operations.
For good performance, it is very important to understand that clone is a fundamental operation, it needs to be fast for your key and data types, because it’s going to be called a lot whenever you change the map.
Why
-
Multiple threads can read this structure even while one thread is updating it. Using a library like arc_swap you can avoid ever blocking readers.
-
Snapshotting this structure is free.
Examples
use std::string::String;
use self::immutable_chunkmap::map::MapM;
let m =
MapM::new()
.insert(String::from("1"), 1).0
.insert(String::from("2"), 2).0
.insert(String::from("3"), 3).0;
assert_eq!(m.get("1"), Option::Some(&1));
assert_eq!(m.get("2"), Option::Some(&2));
assert_eq!(m.get("3"), Option::Some(&3));
assert_eq!(m.get("4"), Option::None);
for (k, v) in &m {
println!("key {}, val: {}", k, v)
}Implementations§
source§impl<K, V, const SIZE: usize> Map<K, V, SIZE>where
K: Ord + Clone,
V: Clone,
impl<K, V, const SIZE: usize> Map<K, V, SIZE>where
K: Ord + Clone,
V: Clone,
sourcepub fn new() -> Self
pub fn new() -> Self
Create a new empty map
Examples found in repository?
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182
fn default() -> Map<K, V, SIZE> {
Map::new()
}
}
impl<K, V, const SIZE: usize> PartialEq for Map<K, V, SIZE>
where
K: PartialEq + Ord + Clone,
V: PartialEq + Clone,
{
fn eq(&self, other: &Map<K, V, SIZE>) -> bool {
self.0 == other.0
}
}
impl<K, V, const SIZE: usize> Eq for Map<K, V, SIZE>
where
K: Eq + Ord + Clone,
V: Eq + Clone,
{
}
impl<K, V, const SIZE: usize> PartialOrd for Map<K, V, SIZE>
where
K: Ord + Clone,
V: PartialOrd + Clone,
{
fn partial_cmp(&self, other: &Map<K, V, SIZE>) -> Option<Ordering> {
self.0.partial_cmp(&other.0)
}
}
impl<K, V, const SIZE: usize> Ord for Map<K, V, SIZE>
where
K: Ord + Clone,
V: Ord + Clone,
{
fn cmp(&self, other: &Map<K, V, SIZE>) -> Ordering {
self.0.cmp(&other.0)
}
}
impl<K, V, const SIZE: usize> Debug for Map<K, V, SIZE>
where
K: Debug + Ord + Clone,
V: Debug + Clone,
{
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
self.0.fmt(f)
}
}
impl<'a, Q, K, V, const SIZE: usize> Index<&'a Q> for Map<K, V, SIZE>
where
Q: Ord,
K: Ord + Clone + Borrow<Q>,
V: Clone,
{
type Output = V;
fn index(&self, k: &Q) -> &V {
self.get(k).expect("element not found for key")
}
}
impl<K, V, const SIZE: usize> FromIterator<(K, V)> for Map<K, V, SIZE>
where
K: Ord + Clone,
V: Clone,
{
fn from_iter<T: IntoIterator<Item = (K, V)>>(iter: T) -> Self {
Map::new().insert_many(iter)
}sourcepub fn downgrade(&self) -> WeakMapRef<K, V, SIZE>
pub fn downgrade(&self) -> WeakMapRef<K, V, SIZE>
Create a weak reference to this map
sourcepub fn strong_count(&self) -> usize
pub fn strong_count(&self) -> usize
Return the number of strong references to this map (see Arc)
sourcepub fn weak_count(&self) -> usize
pub fn weak_count(&self) -> usize
Return the number of weak references to this map (see Arc)
sourcepub fn insert_many<E: IntoIterator<Item = (K, V)>>(&self, elts: E) -> Self
pub fn insert_many<E: IntoIterator<Item = (K, V)>>(&self, elts: E) -> Self
This will insert many elements at once, and is potentially a lot faster than inserting one by one, especially if the data is sorted. It is just a wrapper around the more general update_many method.
#Examples
use self::immutable_chunkmap::map::MapM;
let mut v = vec![(1, 3), (10, 1), (-12, 2), (44, 0), (50, -1)];
v.sort_unstable_by_key(|&(k, _)| k);
let m = MapM::new().insert_many(v.iter().map(|(k, v)| (*k, *v)));
for (k, v) in &v {
assert_eq!(m.get(k), Option::Some(v))
}sourcepub fn remove_many<Q, E>(&self, elts: E) -> Selfwhere
E: IntoIterator<Item = Q>,
Q: Ord,
K: Borrow<Q>,
pub fn remove_many<Q, E>(&self, elts: E) -> Selfwhere
E: IntoIterator<Item = Q>,
Q: Ord,
K: Borrow<Q>,
This will remove many elements at once, and is potentially a lot faster than removing elements one by one, especially if the data is sorted. It is just a wrapper around the more general update_many method.
sourcepub fn update_many<Q, D, E, F>(&self, elts: E, f: F) -> Selfwhere
E: IntoIterator<Item = (Q, D)>,
Q: Ord,
K: Borrow<Q>,
F: FnMut(Q, D, Option<(&K, &V)>) -> Option<(K, V)>,
pub fn update_many<Q, D, E, F>(&self, elts: E, f: F) -> Selfwhere
E: IntoIterator<Item = (Q, D)>,
Q: Ord,
K: Borrow<Q>,
F: FnMut(Q, D, Option<(&K, &V)>) -> Option<(K, V)>,
This method updates multiple bindings in one call. Given an iterator of an arbitrary type (Q, D), where Q is any borrowed form of K, an update function taking Q, D, the current binding in the map, if any, and producing the new binding, if any, this method will produce a new map with updated bindings of many elements at once. It will skip intermediate node allocations where possible. If the data in elts is sorted, it will be able to skip many more intermediate allocations, and can produce a speedup of about 10x compared to inserting/updating one by one. In any case it should always be faster than inserting elements one by one, even with random unsorted keys.
#Examples
use std::iter::FromIterator;
use self::immutable_chunkmap::map::MapM;
let m = MapM::from_iter((0..4).map(|k| (k, k)));
let m = m.update_many(
(0..4).map(|x| (x, ())),
|k, (), cur| cur.map(|(_, c)| (k, c + 1))
);
assert_eq!(
m.into_iter().map(|(k, v)| (*k, *v)).collect::<Vec<_>>(),
vec![(0, 1), (1, 2), (2, 3), (3, 4)]
);sourcepub fn insert(&self, k: K, v: V) -> (Self, Option<V>)
pub fn insert(&self, k: K, v: V) -> (Self, Option<V>)
return a new map with (k, v) inserted into it. If k already exists in the old map, the old binding will be returned, and the new map will contain the new binding. In fact this method is just a wrapper around update.
sourcepub fn insert_cow(&mut self, k: K, v: V) -> Option<V>
pub fn insert_cow(&mut self, k: K, v: V) -> Option<V>
insert in place using copy on write semantics if self is not a
unique reference to the map. see update_cow.
sourcepub fn update<Q, D, F>(&self, q: Q, d: D, f: F) -> (Self, Option<V>)where
Q: Ord,
K: Borrow<Q>,
F: FnMut(Q, D, Option<(&K, &V)>) -> Option<(K, V)>,
pub fn update<Q, D, F>(&self, q: Q, d: D, f: F) -> (Self, Option<V>)where
Q: Ord,
K: Borrow<Q>,
F: FnMut(Q, D, Option<(&K, &V)>) -> Option<(K, V)>,
return a new map with the binding for q, which can be any
borrowed form of k, updated to the result of f. If f returns
None, the binding will be removed from the new map, otherwise
it will be inserted. This function is more efficient than
calling get and then insert, since it makes only one tree
traversal instead of two. This method runs in log(N) time and
space where N is the size of the map.
Examples
use self::immutable_chunkmap::map::MapM;
let (m, _) = MapM::new().update(0, 0, |k, d, _| Some((k, d)));
let (m, _) = m.update(1, 1, |k, d, _| Some((k, d)));
let (m, _) = m.update(2, 2, |k, d, _| Some((k, d)));
assert_eq!(m.get(&0), Some(&0));
assert_eq!(m.get(&1), Some(&1));
assert_eq!(m.get(&2), Some(&2));
let (m, _) = m.update(0, (), |k, (), v| v.map(move |(_, v)| (k, v + 1)));
assert_eq!(m.get(&0), Some(&1));
assert_eq!(m.get(&1), Some(&1));
assert_eq!(m.get(&2), Some(&2));
let (m, _) = m.update(1, (), |_, (), _| None);
assert_eq!(m.get(&0), Some(&1));
assert_eq!(m.get(&1), None);
assert_eq!(m.get(&2), Some(&2));sourcepub fn update_cow<Q, D, F>(&mut self, q: Q, d: D, f: F) -> Option<V>where
Q: Ord,
K: Borrow<Q>,
F: FnMut(Q, D, Option<(&K, &V)>) -> Option<(K, V)>,
pub fn update_cow<Q, D, F>(&mut self, q: Q, d: D, f: F) -> Option<V>where
Q: Ord,
K: Borrow<Q>,
F: FnMut(Q, D, Option<(&K, &V)>) -> Option<(K, V)>,
Perform a copy on write update to the map. In the case that self is a unique reference to the map, then the update will be performed completly in place. self will be mutated, and no previous version will be available. In the case that self has a clone, or clones, then only the parts of the map that need to be mutated will be copied before the update is performed. self will reference the mutated copy, and previous versions of the map will not be modified. self will still share all the parts of the map that did not need to be mutated with any pre existing clones.
COW semantics are a flexible middle way between full peristance and full mutability. Needless to say in the case where you have a unique reference to the map, using update_cow is a lot faster than using update, and a lot more flexible than update_many.
Other than copy on write the semanics of this method are identical to those of update.
#Examples
use self::immutable_chunkmap::map::MapM;
let mut m = MapM::new().update(0, 0, |k, d, _| Some((k, d))).0;
let orig = m.clone();
m.update_cow(1, 1, |k, d, _| Some((k, d))); // copies the original chunk
m.update_cow(2, 2, |k, d, _| Some((k, d))); // doesn't copy anything
assert_eq!(m.len(), 3);
assert_eq!(orig.len(), 1);
assert_eq!(m.get(&0), Some(&0));
assert_eq!(m.get(&1), Some(&1));
assert_eq!(m.get(&2), Some(&2));
assert_eq!(orig.get(&0), Some(&0));
assert_eq!(orig.get(&1), None);
assert_eq!(orig.get(&2), None);sourcepub fn union<F>(&self, other: &Map<K, V, SIZE>, f: F) -> Selfwhere
F: FnMut(&K, &V, &V) -> Option<V>,
pub fn union<F>(&self, other: &Map<K, V, SIZE>, f: F) -> Selfwhere
F: FnMut(&K, &V, &V) -> Option<V>,
Merge two maps together. Bindings that exist in both maps will be passed to f, which may elect to remove the binding by returning None. This function runs in O(log(n) + m) time and space, where n is the size of the largest map, and m is the number of intersecting chunks. It will never be slower than calling update_many on the first map with an iterator over the second, and will be significantly faster if the intersection is minimal or empty.
Examples
use std::iter::FromIterator;
use self::immutable_chunkmap::map::MapM;
let m0 = MapM::from_iter((0..10).map(|k| (k, 1)));
let m1 = MapM::from_iter((10..20).map(|k| (k, 1)));
let m2 = m0.union(&m1, |_k, _v0, _v1| panic!("no intersection expected"));
for i in 0..20 {
assert!(m2.get(&i).is_some())
}
let m3 = MapM::from_iter((5..9).map(|k| (k, 1)));
let m4 = m3.union(&m2, |_k, v0, v1| Some(v0 + v1));
for i in 0..20 {
assert!(
*m4.get(&i).unwrap() ==
*m3.get(&i).unwrap_or(&0) + *m2.get(&i).unwrap_or(&0)
)
}sourcepub fn intersect<F>(&self, other: &Map<K, V, SIZE>, f: F) -> Selfwhere
F: FnMut(&K, &V, &V) -> Option<V>,
pub fn intersect<F>(&self, other: &Map<K, V, SIZE>, f: F) -> Selfwhere
F: FnMut(&K, &V, &V) -> Option<V>,
Produce a map containing the mapping over F of the intersection (by key) of two maps. The function f runs on each intersecting element, and has the option to omit elements from the intersection by returning None, or change the value any way it likes. Runs in O(log(N) + M) time and space where N is the size of the smallest map, and M is the number of intersecting chunks.
Examples
use std::iter::FromIterator;
use self::immutable_chunkmap::map::MapM;
let m0 = MapM::from_iter((0..100000).map(|k| (k, 1)));
let m1 = MapM::from_iter((50..30000).map(|k| (k, 1)));
let m2 = m0.intersect(&m1, |_k, v0, v1| Some(v0 + v1));
for i in 0..100000 {
if i >= 30000 || i < 50 {
assert!(m2.get(&i).is_none());
} else {
assert!(*m2.get(&i).unwrap() == 2);
}
}sourcepub fn diff<F>(&self, other: &Map<K, V, SIZE>, f: F) -> Selfwhere
F: FnMut(&K, &V, &V) -> Option<V>,
K: Debug,
V: Debug,
pub fn diff<F>(&self, other: &Map<K, V, SIZE>, f: F) -> Selfwhere
F: FnMut(&K, &V, &V) -> Option<V>,
K: Debug,
V: Debug,
Produce a map containing the second map subtracted from the first. The function F is called for each intersecting element, and ultimately decides whether it appears in the result, for example, to compute a classical set diff, the function should always return None.
Examples
use std::iter::FromIterator;
use self::immutable_chunkmap::map::MapM;
let m0 = MapM::from_iter((0..10000).map(|k| (k, 1)));
let m1 = MapM::from_iter((50..3000).map(|k| (k, 1)));
let m2 = m0.diff(&m1, |_k, _v0, _v1| None);
m2.invariant();
dbg!(m2.len());
assert!(m2.len() == 10000 - 2950);
for i in 0..10000 {
if i >= 3000 || i < 50 {
assert!(*m2.get(&i).unwrap() == 1);
} else {
assert!(m2.get(&i).is_none());
}
}sourcepub fn get<'a, Q: ?Sized + Ord>(&'a self, k: &Q) -> Option<&'a V>where
K: Borrow<Q>,
pub fn get<'a, Q: ?Sized + Ord>(&'a self, k: &Q) -> Option<&'a V>where
K: Borrow<Q>,
lookup the mapping for k. If it doesn’t exist return None. Runs in log(N) time and constant space. where N is the size of the map.
sourcepub fn get_key<'a, Q: ?Sized + Ord>(&'a self, k: &Q) -> Option<&'a K>where
K: Borrow<Q>,
pub fn get_key<'a, Q: ?Sized + Ord>(&'a self, k: &Q) -> Option<&'a K>where
K: Borrow<Q>,
lookup the mapping for k. Return the key. If it doesn’t exist return None. Runs in log(N) time and constant space. where N is the size of the map.
sourcepub fn get_full<'a, Q: ?Sized + Ord>(&'a self, k: &Q) -> Option<(&'a K, &'a V)>where
K: Borrow<Q>,
pub fn get_full<'a, Q: ?Sized + Ord>(&'a self, k: &Q) -> Option<(&'a K, &'a V)>where
K: Borrow<Q>,
lookup the mapping for k. Return both the key and the value. If it doesn’t exist return None. Runs in log(N) time and constant space. where N is the size of the map.
sourcepub fn remove<Q: Sized + Ord>(&self, k: &Q) -> (Self, Option<V>)where
K: Borrow<Q>,
pub fn remove<Q: Sized + Ord>(&self, k: &Q) -> (Self, Option<V>)where
K: Borrow<Q>,
return a new map with the mapping under k removed. If the binding existed in the old map return it. Runs in log(N) time and log(N) space, where N is the size of the map.
sourcepub fn remove_cow<Q: Sized + Ord>(&mut self, k: &Q) -> Option<V>where
K: Borrow<Q>,
pub fn remove_cow<Q: Sized + Ord>(&mut self, k: &Q) -> Option<V>where
K: Borrow<Q>,
remove in place using copy on write semantics if self is not a
unique reference to the map. see update_cow.
sourcepub fn range<'a, Q>(
&'a self,
lbound: Bound<Q>,
ubound: Bound<Q>
) -> Iter<'a, Q, K, V, SIZE>where
Q: Ord,
K: Borrow<Q>,
pub fn range<'a, Q>(
&'a self,
lbound: Bound<Q>,
ubound: Bound<Q>
) -> Iter<'a, Q, K, V, SIZE>where
Q: Ord,
K: Borrow<Q>,
return an iterator over the subset of elements in the map that are within the specified range.
The returned iterator runs in O(log(N) + M) time, and constant space. N is the number of elements in the tree, and M is the number of elements you examine.
if lbound >= ubound the returned iterator will be empty
Trait Implementations§
source§impl<K, V, const SIZE: usize> Debug for Map<K, V, SIZE>where
K: Debug + Ord + Clone,
V: Debug + Clone,
impl<K, V, const SIZE: usize> Debug for Map<K, V, SIZE>where
K: Debug + Ord + Clone,
V: Debug + Clone,
source§impl<K, V, const SIZE: usize> FromIterator<(K, V)> for Map<K, V, SIZE>where
K: Ord + Clone,
V: Clone,
impl<K, V, const SIZE: usize> FromIterator<(K, V)> for Map<K, V, SIZE>where
K: Ord + Clone,
V: Clone,
source§impl<K, V, const SIZE: usize> Hash for Map<K, V, SIZE>where
K: Hash + Ord + Clone,
V: Hash + Clone,
impl<K, V, const SIZE: usize> Hash for Map<K, V, SIZE>where
K: Hash + Ord + Clone,
V: Hash + Clone,
source§impl<'a, Q, K, V, const SIZE: usize> Index<&'a Q> for Map<K, V, SIZE>where
Q: Ord,
K: Ord + Clone + Borrow<Q>,
V: Clone,
impl<'a, Q, K, V, const SIZE: usize> Index<&'a Q> for Map<K, V, SIZE>where
Q: Ord,
K: Ord + Clone + Borrow<Q>,
V: Clone,
source§impl<'a, K, V, const SIZE: usize> IntoIterator for &'a Map<K, V, SIZE>where
K: 'a + Ord + Clone,
V: 'a + Clone,
impl<'a, K, V, const SIZE: usize> IntoIterator for &'a Map<K, V, SIZE>where
K: 'a + Ord + Clone,
V: 'a + Clone,
source§impl<K, V, const SIZE: usize> Ord for Map<K, V, SIZE>where
K: Ord + Clone,
V: Ord + Clone,
impl<K, V, const SIZE: usize> Ord for Map<K, V, SIZE>where
K: Ord + Clone,
V: Ord + Clone,
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl<K, V, const SIZE: usize> PartialEq<Map<K, V, SIZE>> for Map<K, V, SIZE>where
K: PartialEq + Ord + Clone,
V: PartialEq + Clone,
impl<K, V, const SIZE: usize> PartialEq<Map<K, V, SIZE>> for Map<K, V, SIZE>where
K: PartialEq + Ord + Clone,
V: PartialEq + Clone,
source§impl<K, V, const SIZE: usize> PartialOrd<Map<K, V, SIZE>> for Map<K, V, SIZE>where
K: Ord + Clone,
V: PartialOrd + Clone,
impl<K, V, const SIZE: usize> PartialOrd<Map<K, V, SIZE>> for Map<K, V, SIZE>where
K: Ord + Clone,
V: PartialOrd + Clone,
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self and other) and is used by the <=
operator. Read moreimpl<K, V, const SIZE: usize> Eq for Map<K, V, SIZE>where
K: Eq + Ord + Clone,
V: Eq + Clone,
Auto Trait Implementations§
impl<K, V, const SIZE: usize> RefUnwindSafe for Map<K, V, SIZE>where
K: RefUnwindSafe,
V: RefUnwindSafe,
impl<K, V, const SIZE: usize> Send for Map<K, V, SIZE>where
K: Send + Sync,
V: Send + Sync,
impl<K, V, const SIZE: usize> Sync for Map<K, V, SIZE>where
K: Send + Sync,
V: Send + Sync,
impl<K, V, const SIZE: usize> Unpin for Map<K, V, SIZE>
impl<K, V, const SIZE: usize> UnwindSafe for Map<K, V, SIZE>where
K: RefUnwindSafe,
V: RefUnwindSafe,
Blanket Implementations§
§impl<T> Conv for T
impl<T> Conv for T
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> Rwhere
Self: Borrow<B>,
B: 'a + ?Sized,
R: 'a,
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> Rwhere
Self: Borrow<B>,
B: 'a + ?Sized,
R: 'a,
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R
) -> Rwhere
Self: BorrowMut<B>,
B: 'a + ?Sized,
R: 'a,
fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R
) -> Rwhere
Self: BorrowMut<B>,
B: 'a + ?Sized,
R: 'a,
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> Rwhere
Self: AsRef<U>,
U: 'a + ?Sized,
R: 'a,
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> Rwhere
Self: AsRef<U>,
U: 'a + ?Sized,
R: 'a,
self, then passes self.as_ref() into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> Rwhere
Self: AsMut<U>,
U: 'a + ?Sized,
R: 'a,
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> Rwhere
Self: AsMut<U>,
U: 'a + ?Sized,
R: 'a,
self, then passes self.as_mut() into the pipe
function.§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
Borrow<B> of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
BorrowMut<B> of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
AsRef<R> view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
AsMut<R> view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Selfwhere
Self: Deref<Target = T>,
T: ?Sized,
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Selfwhere
Self: Deref<Target = T>,
T: ?Sized,
Deref::Target of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Selfwhere
Self: DerefMut<Target = T> + Deref,
T: ?Sized,
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Selfwhere
Self: DerefMut<Target = T> + Deref,
T: ?Sized,
Deref::Target of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
.tap_borrow() only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
.tap_borrow_mut() only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
.tap_ref() only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
.tap_ref_mut() only in debug builds, and is erased in release
builds.