[−][src]Module smart_access::traversal
Support for general traversals. Requires traversal
.
This module is essentially a more efficient version of
iter_mut
with some quirks.
The API for traversals mimics the API for affine traversals:
Of<Index, View=V>
corresponds toAt<Index, View=V>
Each<View=V>
corresponds toCps<View=V>
Currently only the basics are implemented: the ()
accessor
can be used to transform (a mutable reference to) any iterator
into an Each
-bound value:
use smart_access::traversal::Each; let mut foo = vec![vec![1, 2], vec![3, 4]]; foo.iter_mut().of(()).each(|subvector| { subvector.iter_mut().of(()).each(|x| { *x += 1; true // true means that the iteration must continue }) }); assert!(foo == vec![vec![2, 3], vec![4, 5]]); foo.iter_mut().of(()).each(|subvector| { subvector.iter_mut().of(()).each(|x| { *x = 6; false // false means that the iteration must stop }) }); assert!(foo == vec![vec![6, 3], vec![6, 5]]);
Traits
Each | An analogue of the |
Of | An analogue of the |