use std::sync::Arc; use autowired::{ LazyComponent, setup_submitted_beans, bean, Autowired}; #[allow(dead_code)] #[derive(Default, LazyComponent)] struct Bar { name: Arc, age: u32, } #[allow(dead_code)] struct Goo { pub list: Vec } #[bean(lazy)] fn build_goo() -> Goo { Goo { list: vec!["hello".to_string()] } } #[test] fn lazy() { setup_submitted_beans(); assert!(!autowired::exist_component::()); assert!(!autowired::exist_component::()); let bar = Autowired::::new(); assert!( bar.name.is_empty()); let goo = Autowired::::new(); assert_eq!("hello", goo.list[0]); assert!(autowired::exist_component::()); assert!(autowired::exist_component::()); }