summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2016-10-30 13:38:25 +0100
committerMatthias Beyer <mail@beyermatthias.de>2016-10-30 13:38:25 +0100
commit3320c135aef3cd9e22d39acca31ead3fe79d088d (patch)
tree63bad1ebcb2dfaa4a38d71cbcf523e4dea6e2431
parentf2f09a2c800ef40ff7f4696171187238f5e3c75b (diff)
Simplify definition of ops
-rw-r--r--src/ops/and.rs9
-rw-r--r--src/ops/bool.rs8
-rw-r--r--src/ops/not.rs8
-rw-r--r--src/ops/or.rs9
-rw-r--r--src/ops/xor.rs9
5 files changed, 15 insertions, 28 deletions
diff --git a/src/ops/and.rs b/src/ops/and.rs
index 322d63b..281b906 100644
--- a/src/ops/and.rs
+++ b/src/ops/and.rs
@@ -13,17 +13,14 @@ use filter::Filter;
#[must_use = "filters are lazy and do nothing unless consumed"]
#[derive(Clone)]
-pub struct And<T, U> {
- a: T,
- b: U
-}
+pub struct And<T, U>(T, U);
impl<T, U> And<T, U> {
pub fn new(a: T, b: U) -> And<T, U> {
- And { a: a, b: b }
+ And(a, b)
}
}
-impl_operators!(And, self e { self.a.filter(e) && self.b.filter(e) }, T, U);
+impl_operators!(And, self e { self.0.filter(e) && self.1.filter(e) }, T, U);
diff --git a/src/ops/bool.rs b/src/ops/bool.rs
index 8ff0acc..6079e22 100644
--- a/src/ops/bool.rs
+++ b/src/ops/bool.rs
@@ -13,14 +13,12 @@ use filter::Filter;
#[must_use = "filters are lazy and do nothing unless consumed"]
#[derive(Clone)]
-pub struct Bool {
- b: bool
-}
+pub struct Bool(bool);
impl Bool {
pub fn new(b: bool) -> Bool {
- Bool { b: b }
+ Bool(b)
}
}
@@ -33,4 +31,4 @@ impl From<bool> for Bool {
}
-impl_operators!(Bool, self e { self.b }, );
+impl_operators!(Bool, self e { self.0 }, );
diff --git a/src/ops/not.rs b/src/ops/not.rs
index eca085c..3fb9db0 100644
--- a/src/ops/not.rs
+++ b/src/ops/not.rs
@@ -13,16 +13,14 @@ use filter::Filter;
#[must_use = "filters are lazy and do nothing unless consumed"]
#[derive(Clone)]
-pub struct Not<T> {
- a: T
-}
+pub struct Not<T>(T);
impl<T> Not<T> {
pub fn new(a: T) -> Not<T> {
- Not { a: a }
+ Not(a)
}
}
-impl_operators!(Not, self e { !self.a.filter(e) }, T);
+impl_operators!(Not, self e { !self.0.filter(e) }, T);
diff --git a/src/ops/or.rs b/src/ops/or.rs
index d0de785..a89d8cc 100644
--- a/src/ops/or.rs
+++ b/src/ops/or.rs
@@ -13,17 +13,14 @@ use filter::Filter;
#[must_use = "filters are lazy and do nothing unless consumed"]
#[derive(Clone)]
-pub struct Or<T, U> {
- a: T,
- b: U
-}
+pub struct Or<T, U>(T, U);
impl<T, U> Or<T, U> {
pub fn new(a: T, b: U) -> Or<T, U> {
- Or { a: a, b: b }
+ Or(a, b)
}
}
-impl_operators!(Or, self e { self.a.filter(e) || self.b.filter(e) }, T, U);
+impl_operators!(Or, self e { self.0.filter(e) || self.1.filter(e) }, T, U);
diff --git a/src/ops/xor.rs b/src/ops/xor.rs
index 6a8a39b..c5c1021 100644
--- a/src/ops/xor.rs
+++ b/src/ops/xor.rs
@@ -13,17 +13,14 @@ use filter::Filter;
#[must_use = "filters are lazy and do nothing unless consumed"]
#[derive(Clone)]
-pub struct XOr<T, U> {
- a: T,
- b: U
-}
+pub struct XOr<T, U>(T, U);
impl<T, U> XOr<T, U> {
pub fn new(a: T, b: U) -> XOr<T, U> {
- XOr { a: a, b: b }
+ XOr(a, b)
}
}
-impl_operators!(XOr, self e { self.a.filter(e) ^ self.b.filter(e) }, T, U);
+impl_operators!(XOr, self e { self.0.filter(e) ^ self.1.filter(e) }, T, U);