diff options
Diffstat (limited to 'src/filters/mod.rs')
-rw-r--r-- | src/filters/mod.rs | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/src/filters/mod.rs b/src/filters/mod.rs index 3d0868b..162b6f8 100644 --- a/src/filters/mod.rs +++ b/src/filters/mod.rs @@ -1,4 +1,3 @@ -#![allow(clippy::new_ret_no_self)] use std::{fmt, ops}; use num_derive::FromPrimitive; @@ -74,13 +73,7 @@ pub trait Filter<Early, Late>: Send + Sync + fmt::Debug { } #[derive(Debug, Clone, Copy)] -pub struct Const(pub bool); - -impl Const { - pub fn new<E, L>(output: bool) -> Box<dyn Filter<E, L>> { - Box::new(Const(output)) - } -} +struct Const(pub bool); impl<E, L> Filter<E, L> for Const { fn filter_early(&self, _: &E) -> Inclusion { @@ -92,6 +85,11 @@ impl<E, L> Filter<E, L> for Const { } } +/// Construct a `Filter` that always returns a fixed value. +pub fn constant<E, L>(output: bool) -> Box<dyn Filter<E, L>> { + Box::new(Const(output)) +} + struct AndFilter<E, L>(Box<dyn Filter<E, L>>, Box<dyn Filter<E, L>>); impl<E, L> Filter<E, L> for AndFilter<E, L> { |