2021-11-05 13:27:34 +00:00
|
|
|
use crate::{LensOver, LensTrait, LensView};
|
2021-11-05 11:03:17 +00:00
|
|
|
|
|
|
|
#[allow(non_camel_case_types)]
|
2021-11-05 14:22:59 +00:00
|
|
|
#[derive(Clone, Copy)]
|
2021-11-05 11:03:17 +00:00
|
|
|
pub struct id;
|
|
|
|
|
2021-11-05 13:27:34 +00:00
|
|
|
impl LensTrait for id {}
|
|
|
|
impl<T> LensView<T> for id {
|
2021-11-05 11:03:17 +00:00
|
|
|
type Field = T;
|
|
|
|
|
|
|
|
fn view(thing: T) -> Self::Field {
|
|
|
|
thing
|
|
|
|
}
|
|
|
|
}
|
2021-11-05 13:27:34 +00:00
|
|
|
impl<T> LensOver<T> for id {
|
2021-11-05 12:05:55 +00:00
|
|
|
fn over<F>(thing: T, f: F) -> T
|
|
|
|
where
|
|
|
|
F: FnOnce(Self::Field) -> Self::Field,
|
|
|
|
{
|
2021-11-05 11:03:17 +00:00
|
|
|
f(thing)
|
|
|
|
}
|
|
|
|
}
|