more specific replace/void for option/result
This commit is contained in:
parent
a32ae322b1
commit
2e9d1ac221
@ -21,8 +21,19 @@ impl Functor for OptionClass {
|
||||
fa.map(f)
|
||||
}
|
||||
|
||||
fn replace<'a, A: 'a, B: 'a>(fa: Self::F<'a, A>, b: B) -> Self::F<'a, B> {
|
||||
fa.map(|_| b)
|
||||
fn replace<'a, A: 'a, B: 'a>(fa: Self::F<'a, A>, b: B) -> Self::F<'a, B>
|
||||
where
|
||||
Self: 'a,
|
||||
{
|
||||
fa?;
|
||||
Self::pure(b)
|
||||
}
|
||||
|
||||
fn void<'a, A: 'a>(fa: Self::F<'a, A>) -> Self::F<'a, ()>
|
||||
where
|
||||
Self: 'a, {
|
||||
fa?;
|
||||
Self::pure(())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,15 @@ impl<E> Functor for ResultClass<E> {
|
||||
where
|
||||
Self: 'a,
|
||||
{
|
||||
fa.map(|_| b)
|
||||
fa?;
|
||||
Self::pure(b)
|
||||
}
|
||||
|
||||
fn void<'a, A: 'a>(fa: Self::F<'a, A>) -> Self::F<'a, ()>
|
||||
where
|
||||
Self: 'a, {
|
||||
fa?;
|
||||
Self::pure(())
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user