main
annieversary 2021-11-18 12:21:55 +00:00
parent 3d8b58202d
commit b86d5ccb27
3 changed files with 4 additions and 8 deletions

View File

@ -144,8 +144,7 @@ where
fn traverse(&self, thing: T) -> Vec<Self::Field> { fn traverse(&self, thing: T) -> Vec<Self::Field> {
let a = A::traverse(&self.0 .0, thing); let a = A::traverse(&self.0 .0, thing);
a.into_iter() a.into_iter()
.map(|v| B::traverse(&self.1 .0, v)) .flat_map(|v| B::traverse(&self.1 .0, v))
.flatten()
.collect() .collect()
} }
} }

View File

@ -1,4 +1,5 @@
#![feature(unboxed_closures, fn_traits, const_trait_impl)] #![feature(unboxed_closures, fn_traits, const_trait_impl)]
#![allow(clippy::type_complexity)]
pub mod combinations; pub mod combinations;
mod fns; mod fns;

View File

@ -21,11 +21,7 @@ pub trait PrismPreview<T> {
F: FnOnce(Self::Field) -> Self::Field, F: FnOnce(Self::Field) -> Self::Field,
T: Clone, T: Clone,
{ {
if let Some(a) = Self::preview(&self, thing.clone()) { Self::preview(self, thing.clone()).map_or(thing, |a| Self::review(self, f(a)))
Self::review(&self, f(a))
} else {
thing
}
} }
fn set(&self, thing: T, v: Self::Field) -> T fn set(&self, thing: T, v: Self::Field) -> T
@ -33,7 +29,7 @@ pub trait PrismPreview<T> {
T: Clone, T: Clone,
Self::Field: Clone, Self::Field: Clone,
{ {
Self::over(self, thing, move |_| v.clone()) Self::over(self, thing, move |_| v)
} }
} }