myopic 0.1.2

A possibly bad lens library for Rust
Documentation
b0VIM 8.10��]�?xnmryanLASLW16010654/d/tools/myopic/src/lens.rsutf-8
3210#"! Utp�a��I�adN����~mkji-���z]

�
�
�
�
�
�
t
_
]
\
4

������_]\[���|[>�
�
�
�
�
z
t
r
q
p


�	�	�	}	V	P	O	3	�����zbICB������qI?98
	��vpoE���gXNHG�����LB<;����uN,"��RNM////// well and is by far the fastest in the micro-benchmarks./// as a pair of getter and setter closures. It appears to inline/// The lens module contains the main implementation of the lens concept}    }        }            self.lhs.set(d, val);            self.rhs.set(&mut val, b);            let mut val = self.lhs.get(d);        fn set(&self, d: &mut D, b: B) {    impl<D, A, B> Setter for ComposedLens<D, A, B> {    }    impl<D, A, B> Optical for ComposedLens<D, A, B> {    }        }            return self.rhs.get(&self.lhs.get(d));        fn get(&self, d: &D) -> B {    impl<D, A, B> Getter for ComposedLens<D, A, B> {    }        type Output = B;        type Input = D;    impl<D, A, B> Lensable for ComposedLens<D, A, B> {    }        }            };                rhs: l2,                lhs: l1,            return ComposedLens {                   l2: Box<dyn Optical<Input = A, Output = B>>) -> Self {        pub fn new(l1: Box<dyn Optical<Input = D, Output = A>>,    impl<D, A, B> ComposedLens<D, A, B> {    }        pub rhs: Box<dyn Optical<Input=A, Output=B>>,        pub lhs: Box<dyn Optical<Input=D, Output=A>>,    pub struct ComposedLens<D, A, B> {    }    impl<D, A> Optical for Lens<D, A> {    }        }            return (self.setter)(d, a);        fn set(&self, d: &mut D, a: A) {    impl<D, A> Setter for Lens<D, A> {    }        }            return (self.getter)(d);        fn get(&self, d: &D) -> A {    impl<D, A> Getter for Lens<D, A> {    }        type Output = A;        type Input = D;    impl<D, A> Lensable for Lens<D, A> {    }        }            return Lens { getter, setter };        pub fn new(getter: Box<GetFun<D, A>>, setter: Box<SetFun<D, A>>) -> Self {    impl<D, A> Lens<D, A> {    }        pub setter: Box<SetFun<D, A>>,        pub getter: Box<GetFun<D, A>>,    pub struct Lens<D, A> {    use crate::{Lensable, Getter, Setter, SetFun, GetFun, Optical};pub mod lens_box {/// The lens_box module contains an implementation of lenses using boxed trait objects.}    }        return (self)(d, a);    fn set(&self, d: &mut D, a: A) {impl<D, A> Setter for dyn Fn(&mut D, A) {}    fn set(&self, d: &mut <Self as Lensable>::Input, a: <Self as Lensable>::Output);pub trait Setter: Lensable {/// with a value of type Outpyt./// The Setter trait is for types that can modify a given value of type Inputpub type SetFun<D, A> = dyn Fn(&mut D, A);/// the value of type D in-place./// The SetFun type is for setters. Note that these setters mutate}pub trait Optical : Lensable + Getter + Setter {/// multiple traits./// The Optical trait is necessary to carry around trait objects satisfying}    }        return (self)(d);    fn get(&self, d: &D) -> A {impl<D, A> Getter for dyn Fn(&D) -> A {}    type Output = A;    type Input = D;impl<D, A> Lensable for dyn Fn(&mut D, A) {}    type Output = A;    type Input = D;impl<D, A> Lensable for dyn Fn(&D) -> A {}    fn get(&self, d: &<Self as Lensable>::Input) -> <Self as Lensable>::Output;pub trait Getter: Lensable {/// a refernence to an Input type./// The Getter trait is for anything which can get an Output type frompub type GetFun<D, A> = dyn Fn(&D) -> A;/// A from a reference to a D./// The GetFun type is for getters. These getters produce a}    type Output;    type Input;pub trait Lensable {/// carry around an Input and Output associated type./// The Lensable trait allows types toad�	I����wmgf=%������]4�
�
�
�
�
�
�
~
x
w
F
+

�����uS;"	��vB�
�
�
�
i
0

�	�	�	�	�	w	J					:	3	,	%	}    }              O2: Optical<Input=A, Output=B> {        where O: Optical<Input=D, Output=A>,    impl<O, O2, D, A, B> Optical for ComposedLens<O, O2>     }        }            self.lhs.set(d, a);            self.rhs.set(&mut a, b);            let mut a = self.lhs.get(d);        fn set(&self, d: &mut O::Input, b: O2::Output) {              O2: Setter + Lensable<Input = O::Output> {        where O: Setter + Lensable + Getter,    impl<O, O2> Setter for ComposedLens<O, O2>    }        }            return self.rhs.get(&self.lhs.get(d));        fn get(&self, d: &O::Input) -> O2::Output {              O2: Getter + Lensable<Input = O::Output> {        where O: Getter + Lensable,    impl<O, O2> Getter for ComposedLens<O, O2>    }        }            };                rhs: o2,                lhs: o,            return ComposedLens {        pub fn new(o: O, o2: O2) -> Self {    impl<O, O2> ComposedLens<O, O2> {    }        type Output = O2::Output;        type Input = O::Input;              O2: Lensable {        where O: Lensable,    impl<O, O2> Lensable for ComposedLens<O, O2>    }        pub rhs: O2,        pub lhs: O,    pub struct ComposedLens<O, O2> {    }    impl<D, A> Optical for Lens<D, A> {    }        }            return (self.setter)(d, a);        fn set(&self, d: &mut D, a: A) {    impl<D, A> Setter for Lens<D, A> {    }        }            return (self.getter)(d);        fn get(&self, d: &D) -> A {    impl<D, A> Getter for Lens<D, A> {    }        type Output = A;        type Input = D;    impl<D, A> Lensable for Lens<D, A> {    }        }            };                setter,                getter,            return Lens {               setter: fn(&mut D, A)) -> Self {ad�a�y."����{YX�
�
>
�����vpo:"	���i_YX'�
�
�
�
�
q
Q
2
,
+

�	�	�	f	<	-	#			������pU<#���wUON���VLFE��i>��������]��j�����a>87�        pub fn new(getter: fn(&D) -> A,    impl<D, A> Lens<D, A> {    }        pub setter: fn(&mut D, A),        pub getter: fn(&D) -> A,    pub struct Lens<D, A> {    use crate::{Lensable, Getter, Setter, Optical};pub mod lens_fn {/// instead of allowing boxed closures like lens_box./// boxed trait objects and requires separate functions for each getter/setter/// It appears that there is no reason to use lens_fn- its no faster then/// regular functions./// of control in the benchmarking to see if Box incurred penality vs/// pairs using function pointers (fn in Rust). This was intended as a kind/// The lens_fn module contains an implementation of lens as gette      impl<L1, L2, D, A, B> Optical for ComposedLens<L1, L2>     }        }            return self.lhs.set(d, val);            self.rhs.set(&mut val, b);            let mut val = self.lhs.get(d);        fn set(&self, d: &mut L1::Input, b: L2::Output) {              L2: Setter + Getter + Lensable<Input = L1::Output> {        where L1: Setter + Getter + Lensable,    impl<L1, L2> Setter for ComposedLens<L1, L2>    }        }            return self.rhs.get(&self.lhs.get(d));        fn get(&self, d: &L1::Input) -> L2::Output {              L2: Getter + Lensable<Input = L1::Output> {        where L1: Getter + Lensable,    impl<L1, L2> Getter for ComposedLens<L1, L2>    }        type Output = L2::Output;        type Input = L1::Input;              L2: Lensable {        where L1: Lensable,    impl<L1, L2> Lensable for ComposedLens<L1, L2>     }        }            }                rhs: l2,                lhs: l1,            ComposedLens {        pub fn new(l1: L1, l2: L2) -> Self {    impl<L1, L2> ComposedLens<L1, L2> {    }        pub rhs: L2,        pub lhs: L1,    pub struct ComposedLens<L1, L2> {    }        }            };                          a: PhantomData,                          d: PhantomData,                          setter: s,            return Lens { getter: g,        pub fn new(g: G, s: S) -> Self {    impl<G, S, D, A> Lens<G, S, D, A> {    }              G: Fn(&D) -> A {        where S: Fn(&mut D, A),    impl<G, S, D, A> Optical for Lens<G, S, D, A>     }        }            return (self.setter)(d, a);        fn set(&self, d: &mut D, a: A) {        where S: Fn(&mut D, A) {    impl<G, S, D, A> Setter for Lens<G, S, D, A>    }        }            return (self.getter)(d);        fn get(&self, d: &D) -> A {        where G: Fn(&D) -> A {    impl<G, S, D, A> Getter for Lens<G, S, D, A>    }        type Output = A;        type Input = D;    impl<G, S, D, A> Lensable for Lens<G, S, D, A> {    }        a: PhantomData<A>,        d: PhantomData<D>,        pub setter: S,        pub getter: G,    pub struct Lens<G, S, D, A> {    // around as type parameters with PhantomData fields instead.    // This causes a compilation error, requiring me to carry them    // to implement Lensable and are not constrained in the implementation.    // available through the Lensable impl because they are required    // NOTE I was not able to get rid of D and A even though they are    use std::marker::PhantomData;    use crate::{Lensable, Getter, Setter, Optical};pub mod lens {/// to specify a lense from a u32 to a u8, for example./// ```/// let lens: Lens<_, _, u32, u8> =/// ```Rust/// users will have to use type inference, or partially specify types like/// I have not been able to implement this module without them, so/// Note that lens does require closure types, which are unnamable.adq������O��\
�
�
�
�
t
S
0
*
)


�
        pub fn new(getter: fn(&D) -> A,    impl<D, A> Lens<D, A> {    }        pub setter: fn(&mut D, A),        pub getter: fn(&D) -> A,    pub struct Lens<D, A> {    use crate::{Lensable, Getter, Setter, Optical};pub mod lens_fn {/// instead of allowing boxed closures like lens_box./// boxed trait objects and requires separate functions for each getter/setter/// It appears that there is no reason to use lens_fn- its no faster then/// regular functions./// of control in the benchmarking to see if Box incurred penality vs/// pairs using function pointers (fn in Rust). This was intended as a kind/// The lens_fn module contains an implementation of lens as getter/setter}    }              L2: Optical<Input=A, Output=B> {        where L1: Optical<Input=D, Output=A>,