Build value factory chains at runtime from lambdas and other sources.
```rust use metafactory::{ metafactory, arglessasfactory, AsFactoryExt };
fn main() { // initialization
let meta_sum = metafactory(
|a: int, b: int| a + b
);
let meta_twice = metafactory(
|val: int| val * 2
);
// plugging in
let any_factory = meta_twice.new(vec![
meta_sum.new(vec![
argless_as_factory(3i),
argless_as_factory(2i),
]).ok().unwrap()
]).ok().unwrap();
// using
let getter = any_factory.as_factory_of::<int>().unwrap();
// note that "take" required no arguments
assert_eq!(getter.take().value, 12);
} ```
Put this in your Cargo.toml
:
toml
[dependencies]
metafactory = "*"
And this in your crate root:
rust
extern crate metafactory;
MIT