[][src]Module myopic::lens

Modules

lens

The lens module contains the main implementation of the lens concept as a pair of getter and setter closures. It appears to inline well and is by far the fastest in the micro-benchmarks.

lens_box

The lens_box module contains an implementation of lenses using boxed trait objects.

lens_fn

The lens_fn module contains an implementation of lens as getter/setter pairs using function pointers (fn in Rust). This was intended as a kind of control in the benchmarking to see if Box incurred penality vs regular functions. It appears that there is no reason to use lens_fn- its no faster then boxed trait objects and requires separate functions for each getter/setter instead of allowing boxed closures like lens_box.

Traits

Getter

The Getter trait is for anything which can get an Output type from a refernence to an Input type.

Lensable

The Lensable trait allows types to carry around an Input and Output associated type.

Optical

The Optical trait is necessary to carry around trait objects satisfying multiple traits.

Setter

The Setter trait is for types that can modify a given value of type Input with a value of type Outpyt.

Type Definitions

GetFun

The GetFun type is for getters. These getters produce a A from a reference to a D.

SetFun

The SetFun type is for setters. Note that these setters mutate the value of type D in-place.