pl-lens
This Rust library provides support for lenses, which are a mechanism in functional programming for focusing on a part of a complex data structure.
Usage
Add a dependency (or two) to your Cargo.toml:
[]
= "1.0"
Then, in your crate:
use *;
Examples
A Lens can be used to transform a conceptually-immutable data structure by changing only a portion of the data. Let's demonstrate with an example:
let p0 = Person ;
assert_eq!;
assert_eq!;
let p1 = lens!.set;
assert_eq!;
assert_eq!;
License
pl-lens is distributed under an MIT license. See LICENSE for more details.