| Crates.io | microrust_inject |
| lib.rs | microrust_inject |
| version | 0.0.0-alpha.3 |
| created_at | 2025-08-03 16:43:10.604284+00 |
| updated_at | 2025-08-03 19:04:03.969718+00 |
| description | MicroRust Dependency Injection |
| homepage | |
| repository | |
| max_upload_size | |
| id | 1779882 |
| size | 22,458 |
Asynchronous dependency injection.
Work in progress...
use microrust_inject::{get_instance, inject_singleton};
struct MyStruct {}
#[inject_singleton(new)]
impl MyStruct {
pub fn new() -> Self {
println!("MyStruct:new() called");
Self {}
}
async fn print(&self) {
println!("Hello, MyStruct");
}
}
#[async_std::main]
async fn main() {
let inst = get_instance::<MyStruct>();
// let inst: Arc<MyStruct> = get_instance();
inst.print().await;
}