partial_function

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

commit edf2c8c5a57908431567ee37c2e780f621632628
parent ba8efd979c4ecf294847ddebb3aea4bdb071d843
Author: Joël Lupien (Jojolepro) <jojolepro@jojolepro.com>
Date:   Mon, 25 May 2020 08:27:22 -0400

macro example in readme

Diffstat:
MREADME.md | 16++++++++++++++++
1 file changed, 16 insertions(+), 0 deletions(-)

diff --git a/README.md b/README.md @@ -22,6 +22,14 @@ let p = PartialFunction::new() .build(); assert_eq!(p.eval(5.0), Some(10.0)); ``` +or even as: +```rust +let p = partfn! { + [0.0, 5.0]: x -> x, + [5.0, 10.0]: x -> x * 2, +}; +assert_eq!(p.eval(5.0), Some(10.0)); +``` ## Lower Partial Function @@ -40,6 +48,14 @@ let f = LowerPartialFunction::new() .build(); assert_eq!(f.eval(5.0), Some(10.0)); ``` +or even as: +```rust +let f = lowpartfn! { + [0.0]: x -> x, + [5.0]: x -> x * 2, +}; +assert_eq!(f.eval(5.0), Some(10.0)); +``` ## Adding To Your Project Add the following to your Cargo.toml: