Crates.io | maller |
lib.rs | maller |
version | 0.1.0 |
source | src |
created_at | 2023-04-30 14:46:40.30173 |
updated_at | 2023-04-30 14:46:40.30173 |
description | a rust library crate that calls closures depending on the input data |
homepage | |
repository | https://github.com/MAKA-Rustcean/maller.git |
max_upload_size | |
id | 852815 |
size | 21,592 |
This is a small Rust library that provides a Maller structure, which allows you to call closures by key.
Add this to your Cargo.toml file:
[dependencies]
maller = "0.1"
cargo add maller
Then, you can use the Maller
and Input
structures in your Rust code
The input
and new_input
functions from utils
allow you to create an input closure. More details in the documentation.
use maller::{input, Maller};
fn main() {
let mut con=0;
let c1=|x|{con+=1;2};
let c2=|x|3;
let mut maller=Maller::from_iter(
[(898, input(c1)),
(500, input(c2))]
);
assert_eq!(maller.call(&898).unwrap(),2);
}
This code is licensed under the "Apache-2.0 OR Unlicense"
License.