This commit is contained in:
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> {
let a = A::traverse(&self.0 .0, thing);
a.into_iter()
.map(|v| B::traverse(&self.1 .0, v))
.flatten()
.flat_map(|v| B::traverse(&self.1 .0, v))
.collect()
}
}

View file

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

View file

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