From 3320c135aef3cd9e22d39acca31ead3fe79d088d Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sun, 30 Oct 2016 13:38:25 +0100 Subject: Simplify definition of ops --- src/ops/and.rs | 9 +++------ src/ops/bool.rs | 8 +++----- src/ops/not.rs | 8 +++----- src/ops/or.rs | 9 +++------ src/ops/xor.rs | 9 +++------ 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 { - a: T, - b: U -} +pub struct And(T, U); impl And { pub fn new(a: T, b: U) -> And { - 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 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 { - a: T -} +pub struct Not(T); impl Not { pub fn new(a: T) -> Not { - 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 { - a: T, - b: U -} +pub struct Or(T, U); impl Or { pub fn new(a: T, b: U) -> Or { - 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 { - a: T, - b: U -} +pub struct XOr(T, U); impl XOr { pub fn new(a: T, b: U) -> XOr { - 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); -- cgit v1.2.3