summaryrefslogtreecommitdiffstats
path: root/src/ops
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2016-08-10 10:08:37 +0200
committerMatthias Beyer <mail@beyermatthias.de>2016-08-11 15:59:43 +0200
commite57b599ee19a0d11bcb73151c1f19e61e89c3be8 (patch)
tree06c586d2c1474f9bbbf685b4079938106f2a36fe /src/ops
parentb79d8963fc79da66b9efc55fd5fa45bb0b98c051 (diff)
Make everything work
With patches from Marcel Müller <neikos@neikos.email>
Diffstat (limited to 'src/ops')
-rw-r--r--src/ops/and.rs16
-rw-r--r--src/ops/not.rs10
-rw-r--r--src/ops/or.rs16
3 files changed, 24 insertions, 18 deletions
diff --git a/src/ops/and.rs b/src/ops/and.rs
index 8d79b42..074446e 100644
--- a/src/ops/and.rs
+++ b/src/ops/and.rs
@@ -1,21 +1,23 @@
use filter::Filter;
-pub struct And<T> {
- a: Box<Filter<T>>,
- b: Box<Filter<T>>
+#[must_use = "filters are lazy and do nothing unless consumed"]
+#[derive(Clone)]
+pub struct And<T, U> {
+ a: T,
+ b: U
}
-impl<T> And<T> {
+impl<T, U> And<T, U> {
- pub fn new(a: Box<Filter<T>>, b: Box<Filter<T>>) -> And<T> {
+ pub fn new(a: T, b: U) -> And<T, U> {
And { a: a, b: b }
}
}
-impl<T> Filter<T> for And<T> {
+impl<I, T: Filter<I>, U: Filter<I>> Filter<I> for And<T, U> {
- fn filter(&self, e: &T) -> bool {
+ fn filter(&self, e: &I) -> bool {
self.a.filter(e) && self.b.filter(e)
}
diff --git a/src/ops/not.rs b/src/ops/not.rs
index a7c5c76..895b7de 100644
--- a/src/ops/not.rs
+++ b/src/ops/not.rs
@@ -1,20 +1,22 @@
use filter::Filter;
+#[must_use = "filters are lazy and do nothing unless consumed"]
+#[derive(Clone)]
pub struct Not<T> {
- a: Box<Filter<T>>
+ a: T
}
impl<T> Not<T> {
- pub fn new(a: Box<Filter<T>>) -> Not<T> {
+ pub fn new(a: T) -> Not<T> {
Not { a: a }
}
}
-impl<T> Filter<T> for Not<T> {
+impl<I, T: Filter<I>> Filter<I> for Not<T> {
- fn filter(&self, e: &T) -> bool {
+ fn filter(&self, e: &I) -> bool {
!self.a.filter(e)
}
diff --git a/src/ops/or.rs b/src/ops/or.rs
index b001d75..c6f6a67 100644
--- a/src/ops/or.rs
+++ b/src/ops/or.rs
@@ -1,21 +1,23 @@
use filter::Filter;
-pub struct Or<T> {
- a: Box<Filter<T>>,
- b: Box<Filter<T>>
+#[must_use = "filters are lazy and do nothing unless consumed"]
+#[derive(Clone)]
+pub struct Or<T, U> {
+ a: T,
+ b: U
}
-impl<T> Or<T> {
+impl<T, U> Or<T, U> {
- pub fn new(a: Box<Filter<T>>, b: Box<Filter<T>>) -> Or<T> {
+ pub fn new(a: T, b: U) -> Or<T, U> {
Or { a: a, b: b }
}
}
-impl<T> Filter<T> for Or<T> {
+impl<I, T: Filter<I>, U: Filter<I>> Filter<I> for Or<T, U> {
- fn filter(&self, e: &T) -> bool {
+ fn filter(&self, e: &I) -> bool {
self.a.filter(e) || self.b.filter(e)
}