summaryrefslogtreecommitdiffstats
path: root/src/ops/failable.rs
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2018-04-29 10:42:30 +0200
committerMatthias Beyer <mail@beyermatthias.de>2018-04-29 10:48:28 +0200
commit68df53a1467f0dd9c37114cdb7980783fb1fa3a0 (patch)
tree32213b67883891866a51c38f17e4ff46e26e2d9a /src/ops/failable.rs
parentb531c50e550d05c95ea02370ba02c0535a4ef5f5 (diff)
Make error type associated
The problem with the FailingFilter was, that the error type was not an associated type but a generic type parameter. This patch fixes this.
Diffstat (limited to 'src/ops/failable.rs')
-rw-r--r--src/ops/failable.rs29
1 files changed, 16 insertions, 13 deletions
diff --git a/src/ops/failable.rs b/src/ops/failable.rs
index a3277dc..1b4ca22 100644
--- a/src/ops/failable.rs
+++ b/src/ops/failable.rs
@@ -9,43 +9,46 @@
//! Will be automatically included when including `filter::Filter`, so importing this module
//! shouldn't be necessary.
//!
-use std::marker::PhantomData;
use filter::Filter;
use failable::filter::FailableFilter;
#[must_use = "filters are lazy and do nothing unless consumed"]
#[derive(Clone)]
-pub struct IntoFailable<F, E>(F, PhantomData<E>);
+pub struct IntoFailable<F>(F);
-impl<F, E> IntoFailable<F, E> {
- pub fn new(a: F) -> IntoFailable<F, E> {
- IntoFailable(a, PhantomData)
+impl<F> IntoFailable<F> {
+ pub fn new(a: F) -> IntoFailable<F> {
+ IntoFailable(a)
}
}
-impl<F, N, E> FailableFilter<N, E> for IntoFailable<F, E>
+impl<F, N> FailableFilter<N> for IntoFailable<F>
where F: Filter<N>,
{
- fn filter(&self, e: &N) -> Result<bool, E> {
+ type Error = ();
+
+ fn filter(&self, e: &N) -> Result<bool, Self::Error> {
Ok(self.0.filter(e))
}
}
#[must_use = "filters are lazy and do nothing unless consumed"]
#[derive(Clone)]
-pub struct AsFailable<'a, F: 'a + ?Sized, E>(&'a F, PhantomData<E>);
+pub struct AsFailable<'a, F: 'a + ?Sized>(&'a F);
-impl<'a, F: 'a + ?Sized, E> AsFailable<'a, F, E> {
- pub fn new(a: &'a F) -> AsFailable<F, E> {
- AsFailable(a, PhantomData)
+impl<'a, F: 'a + ?Sized> AsFailable<'a, F> {
+ pub fn new(a: &'a F) -> AsFailable<F> {
+ AsFailable(a)
}
}
-impl<'a, F, N, E> FailableFilter<N, E> for AsFailable<'a, F, E>
+impl<'a, F, N> FailableFilter<N> for AsFailable<'a, F>
where F: Filter<N> + 'a + ?Sized,
{
- fn filter(&self, e: &N) -> Result<bool, E> {
+ type Error = ();
+
+ fn filter(&self, e: &N) -> Result<bool, Self::Error> {
Ok(self.0.filter(e))
}
}