Module im::lens [] [src]

A view into a data structure.

A lens describes a view into a data structure, like an index or key lookup, with the ability to modify what it sees. It provides a get operation (get the thing we're a lens for) and a set operation (modify the data structure we're a lens into with the a value for the thing).

Lenses are composable, so that if you have a lens from A to a thing B inside A, and you have a lens from B to another thing C inside B, you can compose them to make a lens from A directly into C.

There are two kinds of lenses defined here: PartialLens, which is a lens into something which doesn't necessarily exist (such as a map key), and Lens, which must always be able to succeed. All Lenses are also PartialLenses, but the opposite is not true.

Structs

Compose

Traits

Lens

A lens from From to To where From is guaranteed to contain the focus of the lens (ie. get and put operations cannot fail).

PartialLens

A lens from From to To where the focus of the lens isn't guaranteed to exist inside From. Operations on these lenses therefore return Options.

Functions

compose

Compose a lens from A to B with a lens from B to C, yielding a lens from A to C.