dyn_inject/lib.rs
1//! This crates provides utilities for dependency injection in Rust,
2//! also supporting `dyn Trait` trait objects instead of only static, sized types.
3//!
4//! # Example
5//! ```
6//! use dyn_inject::Registry;
7//!
8//! trait Foo {
9//! fn foo();
10//! }
11//!
12//! struct Bar;
13//!
14//! impl Foo for Bar {
15//! fn foo() {
16//! println!("Hello");
17//! }
18//! }
19//!
20//! fn main() {
21//! let mut registry = Registry::new();
22//! registry.put_dyn::<dyn Foo>(Bar);
23//! // Calls Bar::foo()
24//! registry.get_dyn::<dyn Foo>().unwrap().foo();
25//! }
26//! ```
27
28#![feature(unsize)]
29#![feature(thin_box)]
30
31pub mod registry;
32
33pub use registry::Registry;