[−][src]Trait smart_access::At
A smart access protocol.
It is intended to be used through a Cps
-bounded type.
Associated Types
Loading content...Required methods
fn access_at<R, F>(&mut self, i: Index, f: F) -> Option<R> where
F: FnOnce(&mut Self::View) -> R,
F: FnOnce(&mut Self::View) -> R,
Accesses data at a specified index.
If there is some data (or some bidirectional procedure) associated
with the index then access_at
must apply f
to this data.
If the transformation result can be placed back into self
then
it must be placed back and access_at
must return Some(f(data))
.
Otherwise None
must be returned and self
must stay unchanged.
In essence access_at
returns None
if and only if self
has
not been touched.
Note
The following two cases are indistinguishable:
- a view couldn't be obtained (and thus
f
had not been called) f
had been called but failed to mutate the view in a meaningful way
If you need to distinguish between these cases you can use some side-effect of f
.
Implementations on Foreign Types
impl<T> At<()> for Option<T>
[src]
type View = T
fn access_at<R, F>(&mut self, _: (), f: F) -> Option<R> where
F: FnOnce(&mut T) -> R,
[src]
F: FnOnce(&mut T) -> R,
impl<T, S> At<()> for Result<T, S>
[src]
type View = T
fn access_at<R, F>(&mut self, _: (), f: F) -> Option<R> where
F: FnOnce(&mut T) -> R,
[src]
F: FnOnce(&mut T) -> R,
impl<T> At<()> for Vec<T>
[src]
type View = [T]
fn access_at<R, F>(&mut self, _: (), f: F) -> Option<R> where
F: FnOnce(&mut Self::View) -> R,
[src]
F: FnOnce(&mut Self::View) -> R,
impl<T> At<usize> for Vec<T>
[src]
type View = T
fn access_at<R, F>(&mut self, i: usize, f: F) -> Option<R> where
F: FnOnce(&mut Self::View) -> R,
[src]
F: FnOnce(&mut Self::View) -> R,
impl<T> At<Range<usize>> for Vec<T>
[src]
type View = Vec<T>
fn access_at<R, F>(&mut self, i: Range<usize>, f: F) -> Option<R> where
F: FnOnce(&mut Self::View) -> R,
[src]
F: FnOnce(&mut Self::View) -> R,
impl<T> At<RangeFrom<usize>> for Vec<T>
[src]
type View = Vec<T>
fn access_at<R, F>(&mut self, i: RangeFrom<usize>, f: F) -> Option<R> where
F: FnOnce(&mut Self::View) -> R,
[src]
F: FnOnce(&mut Self::View) -> R,
impl<T> At<RangeFull> for Vec<T>
[src]
type View = Vec<T>
fn access_at<R, F>(&mut self, _: RangeFull, f: F) -> Option<R> where
F: FnOnce(&mut Self::View) -> R,
[src]
F: FnOnce(&mut Self::View) -> R,
impl<T> At<RangeInclusive<usize>> for Vec<T>
[src]
type View = Vec<T>
fn access_at<R, F>(&mut self, i: RangeInclusive<usize>, f: F) -> Option<R> where
F: FnOnce(&mut Self::View) -> R,
[src]
F: FnOnce(&mut Self::View) -> R,
impl<T> At<RangeTo<usize>> for Vec<T>
[src]
type View = Vec<T>
fn access_at<R, F>(&mut self, i: RangeTo<usize>, f: F) -> Option<R> where
F: FnOnce(&mut Self::View) -> R,
[src]
F: FnOnce(&mut Self::View) -> R,
impl<T> At<RangeToInclusive<usize>> for Vec<T>
[src]
type View = Vec<T>
fn access_at<R, F>(&mut self, i: RangeToInclusive<usize>, f: F) -> Option<R> where
F: FnOnce(&mut Self::View) -> R,
[src]
F: FnOnce(&mut Self::View) -> R,
impl<'_, Q: ?Sized, K, V> At<&'_ Q> for HashMap<K, V> where
K: Borrow<Q> + Eq + Hash,
Q: Eq + Hash,
[src]
K: Borrow<Q> + Eq + Hash,
Q: Eq + Hash,
type View = V
fn access_at<R, F>(&mut self, i: &Q, f: F) -> Option<R> where
F: FnOnce(&mut V) -> R,
[src]
F: FnOnce(&mut V) -> R,
impl<K, V> At<(K, V)> for HashMap<K, V> where
K: Eq + Hash,
[src]
K: Eq + Hash,
type View = V
fn access_at<R, F>(&mut self, kv: (K, V), f: F) -> Option<R> where
F: FnOnce(&mut V) -> R,
[src]
F: FnOnce(&mut V) -> R,
impl<K, V, M> At<(K, V, M)> for HashMap<K, V> where
K: Eq + Hash,
M: FnOnce(&mut V),
[src]
K: Eq + Hash,
M: FnOnce(&mut V),
type View = V
fn access_at<R, F>(&mut self, kvm: (K, V, M), f: F) -> Option<R> where
F: FnOnce(&mut V) -> R,
[src]
F: FnOnce(&mut V) -> R,
impl<'_, Q: ?Sized, K, V> At<&'_ Q> for BTreeMap<K, V> where
K: Borrow<Q> + Ord,
Q: Ord,
[src]
K: Borrow<Q> + Ord,
Q: Ord,
type View = V
fn access_at<R, F>(&mut self, i: &Q, f: F) -> Option<R> where
F: FnOnce(&mut V) -> R,
[src]
F: FnOnce(&mut V) -> R,
impl<K, V> At<(K, V)> for BTreeMap<K, V> where
K: Ord,
[src]
K: Ord,
type View = V
fn access_at<R, F>(&mut self, kv: (K, V), f: F) -> Option<R> where
F: FnOnce(&mut V) -> R,
[src]
F: FnOnce(&mut V) -> R,
impl<K, V, M> At<(K, V, M)> for BTreeMap<K, V> where
K: Ord,
M: FnOnce(&mut V),
[src]
K: Ord,
M: FnOnce(&mut V),
type View = V
fn access_at<R, F>(&mut self, kvm: (K, V, M), f: F) -> Option<R> where
F: FnOnce(&mut V) -> R,
[src]
F: FnOnce(&mut V) -> R,
impl<T> At<(T,)> for HashSet<T> where
T: Eq + Hash,
[src]
T: Eq + Hash,
type View = Self
fn access_at<R, F>(&mut self, item: (T,), f: F) -> Option<R> where
F: FnOnce(&mut Self) -> R,
[src]
F: FnOnce(&mut Self) -> R,
impl<T> At<(T, ())> for HashSet<T> where
T: Eq + Hash,
[src]
T: Eq + Hash,
type View = T
fn access_at<R, F>(&mut self, item: (T, ()), f: F) -> Option<R> where
F: FnOnce(&mut T) -> R,
[src]
F: FnOnce(&mut T) -> R,
impl<'_, Q: ?Sized, T> At<&'_ Q> for HashSet<T> where
T: Borrow<Q> + Eq + Hash,
Q: Eq + Hash,
[src]
T: Borrow<Q> + Eq + Hash,
Q: Eq + Hash,
type View = T
fn access_at<R, F>(&mut self, i: &Q, f: F) -> Option<R> where
F: FnOnce(&mut T) -> R,
[src]
F: FnOnce(&mut T) -> R,
impl<T> At<(T,)> for BTreeSet<T> where
T: Ord,
[src]
T: Ord,
type View = Self
fn access_at<R, F>(&mut self, item: (T,), f: F) -> Option<R> where
F: FnOnce(&mut Self) -> R,
[src]
F: FnOnce(&mut Self) -> R,
impl<T> At<(T, ())> for BTreeSet<T> where
T: Ord,
[src]
T: Ord,
type View = T
fn access_at<R, F>(&mut self, item: (T, ()), f: F) -> Option<R> where
F: FnOnce(&mut T) -> R,
[src]
F: FnOnce(&mut T) -> R,
impl<'_, Q: ?Sized, T> At<&'_ Q> for BTreeSet<T> where
T: Borrow<Q> + Ord,
Q: Ord,
[src]
T: Borrow<Q> + Ord,
Q: Ord,
type View = T
fn access_at<R, F>(&mut self, i: &Q, f: F) -> Option<R> where
F: FnOnce(&mut T) -> R,
[src]
F: FnOnce(&mut T) -> R,
Implementors
impl<'a, I, B, V: ?Sized> At<Bounds<B>> for I where
I: Iterator<Item = &'a mut V>,
[&'a mut V]: At<B, View = [&'a mut V]>,
V: 'a,
[src]
I: Iterator<Item = &'a mut V>,
[&'a mut V]: At<B, View = [&'a mut V]>,
V: 'a,
type View = Slice<V>
fn access_at<R, F>(&mut self, i: Bounds<B>, f: F) -> Option<R> where
F: FnOnce(&mut Slice<V>) -> R,
[src]
F: FnOnce(&mut Slice<V>) -> R,
impl<T> At<Range<usize>> for Slice<T>
[src]
type View = Slice<T>
fn access_at<R, F>(&mut self, i: Range<usize>, f: F) -> Option<R> where
F: FnOnce(&mut Self::View) -> R,
[src]
F: FnOnce(&mut Self::View) -> R,
impl<T> At<Range<usize>> for [T]
[src]
type View = [T]
fn access_at<R, F>(&mut self, i: Range<usize>, f: F) -> Option<R> where
F: FnOnce(&mut Self::View) -> R,
[src]
F: FnOnce(&mut Self::View) -> R,
impl<T> At<RangeFrom<usize>> for Slice<T>
[src]
type View = Slice<T>
fn access_at<R, F>(&mut self, i: RangeFrom<usize>, f: F) -> Option<R> where
F: FnOnce(&mut Self::View) -> R,
[src]
F: FnOnce(&mut Self::View) -> R,
impl<T> At<RangeFrom<usize>> for [T]
[src]
type View = [T]
fn access_at<R, F>(&mut self, i: RangeFrom<usize>, f: F) -> Option<R> where
F: FnOnce(&mut Self::View) -> R,
[src]
F: FnOnce(&mut Self::View) -> R,
impl<T> At<RangeFull> for Slice<T>
[src]
type View = Slice<T>
fn access_at<R, F>(&mut self, i: RangeFull, f: F) -> Option<R> where
F: FnOnce(&mut Self::View) -> R,
[src]
F: FnOnce(&mut Self::View) -> R,
impl<T> At<RangeFull> for [T]
[src]
type View = [T]
fn access_at<R, F>(&mut self, _: RangeFull, f: F) -> Option<R> where
F: FnOnce(&mut Self::View) -> R,
[src]
F: FnOnce(&mut Self::View) -> R,
impl<T> At<RangeInclusive<usize>> for Slice<T>
[src]
type View = Slice<T>
fn access_at<R, F>(&mut self, i: RangeInclusive<usize>, f: F) -> Option<R> where
F: FnOnce(&mut Self::View) -> R,
[src]
F: FnOnce(&mut Self::View) -> R,
impl<T> At<RangeInclusive<usize>> for [T]
[src]
type View = [T]
fn access_at<R, F>(&mut self, i: RangeInclusive<usize>, f: F) -> Option<R> where
F: FnOnce(&mut Self::View) -> R,
[src]
F: FnOnce(&mut Self::View) -> R,
impl<T> At<RangeTo<usize>> for Slice<T>
[src]
type View = Slice<T>
fn access_at<R, F>(&mut self, i: RangeTo<usize>, f: F) -> Option<R> where
F: FnOnce(&mut Self::View) -> R,
[src]
F: FnOnce(&mut Self::View) -> R,
impl<T> At<RangeTo<usize>> for [T]
[src]
type View = [T]
fn access_at<R, F>(&mut self, i: RangeTo<usize>, f: F) -> Option<R> where
F: FnOnce(&mut Self::View) -> R,
[src]
F: FnOnce(&mut Self::View) -> R,
impl<T> At<RangeToInclusive<usize>> for Slice<T>
[src]
type View = Slice<T>
fn access_at<R, F>(&mut self, i: RangeToInclusive<usize>, f: F) -> Option<R> where
F: FnOnce(&mut Self::View) -> R,
[src]
F: FnOnce(&mut Self::View) -> R,
impl<T> At<RangeToInclusive<usize>> for [T]
[src]
type View = [T]
fn access_at<R, F>(&mut self, i: RangeToInclusive<usize>, f: F) -> Option<R> where
F: FnOnce(&mut Self::View) -> R,
[src]
F: FnOnce(&mut Self::View) -> R,
impl<T> At<usize> for Slice<T>
[src]
type View = T
fn access_at<R, F>(&mut self, i: usize, f: F) -> Option<R> where
F: FnOnce(&mut T) -> R,
[src]
F: FnOnce(&mut T) -> R,