2021-11-05 15:55:49 +00:00
|
|
|
use crate::{
|
|
|
|
lenses::{LensOver, LensView},
|
|
|
|
OpticsTrait,
|
|
|
|
};
|
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 15:55:49 +00:00
|
|
|
impl OpticsTrait for id {}
|
2021-11-05 13:27:34 +00:00
|
|
|
impl<T> LensView<T> for id {
|
2021-11-05 11:03:17 +00:00
|
|
|
type Field = T;
|
|
|
|
|
2021-11-11 10:39:47 +00:00
|
|
|
fn view(&self, thing: T) -> Self::Field {
|
2021-11-05 11:03:17 +00:00
|
|
|
thing
|
|
|
|
}
|
|
|
|
}
|
2021-11-05 13:27:34 +00:00
|
|
|
impl<T> LensOver<T> for id {
|
2021-11-11 10:39:47 +00:00
|
|
|
fn over<F>(&self, thing: T, f: F) -> T
|
2021-11-05 12:05:55 +00:00
|
|
|
where
|
|
|
|
F: FnOnce(Self::Field) -> Self::Field,
|
|
|
|
{
|
2021-11-05 11:03:17 +00:00
|
|
|
f(thing)
|
|
|
|
}
|
|
|
|
}
|