partial_function

[Done] Partial Function library for Rust.
git clone https://git.jojolepro.com/partial_function.git
Log | Files | Refs | README | LICENSE

commit 40caa7876cca52d75bb7ed61cc58765b5f8c7462
parent 13abc73ab4d3f708fd65c6e43e2fc80eee509c2d
Author: Joël Lupien (Jojolepro) <jojolepro@jojolepro.com>
Date:   Sun, 24 May 2020 09:47:04 -0400

rustfmt

Diffstat:
Msrc/lib.rs | 6+-----
Mtests/tests.rs | 16++++++++++++----
2 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/src/lib.rs b/src/lib.rs @@ -151,10 +151,7 @@ impl<B: PartialOrd, O> LowerPartialFunctionBuilder<B, O> { /// Adds a bounded function bounded between [lower,higher[ of function func. pub fn with(mut self, lower: B, func: Box<dyn Fn(B) -> O>) -> Self { debug_assert!(self.can_insert(&lower)); - let f = LowerBoundedFunction { - func, - lower, - }; + let f = LowerBoundedFunction { func, lower }; self.funcs.push(f); self } @@ -171,4 +168,3 @@ impl<B: PartialOrd, O> LowerPartialFunctionBuilder<B, O> { LowerPartialFunction { funcs: self.funcs } } } - diff --git a/tests/tests.rs b/tests/tests.rs @@ -6,22 +6,30 @@ mod tests { use partial_function::*; #[test] fn single() { - let p = PartialFunction::new().with(0.0, 1.0, Box::new(|x| x)).build(); + let p = PartialFunction::new() + .with(0.0, 1.0, Box::new(|x| x)) + .build(); assert_eq!(Some(0.5), p.eval(0.5)); } #[test] fn single_start() { - let p = PartialFunction::new().with(0.0, 1.0, Box::new(|x| x)).build(); + let p = PartialFunction::new() + .with(0.0, 1.0, Box::new(|x| x)) + .build(); assert_eq!(Some(0.0), p.eval(0.0)); } #[test] fn single_ending() { - let p = PartialFunction::new().with(0.0, 1.0, Box::new(|x| x)).build(); + let p = PartialFunction::new() + .with(0.0, 1.0, Box::new(|x| x)) + .build(); assert_eq!(Some(1.0), p.eval(1.0)); } #[test] fn single_nan() { - let p = PartialFunction::new().with(0.0, 1.0, Box::new(|x| x)).build(); + let p = PartialFunction::new() + .with(0.0, 1.0, Box::new(|x| x)) + .build(); assert!(p.eval(999.0).is_none()); } #[test]