Expand description
Ware provides mutable and immutable middleware abstractions. Basically, it means that you can pass one variable through a series of functions that all have the ability to modify this variable, therefore sending this modified version of it further down the chain.
Ware is used like this:
use ware::Ware;
use std::ops::{Mul, Sub};
fn main() {
let mut chain: Ware<i32> = Ware::new();
chain.wrap(Box::new(|mut num| {
*num = num.mul(5);
}));
chain.wrap(Box::new(|mut num| {
*num = num.sub(2);
}));
let result = chain.run(5);
assert_eq!(result, 23);
}
Modules
- An immutable version of ware. Does not use RefCells, instead relying on the user to return the modified variable in the closure.
Structs
- A middleware chain.
Type Definitions
- Shorthand version of
RefMut<T>
, if you don’t want to importRefMut
.