use autowired::{setup_submitted_beans, bean, Autowired}; #[allow(dead_code)] struct Bar { name: String, } #[bean(option)] fn build_bar_none() -> Option { None } #[allow(dead_code)] struct Goo { pub list: Vec, } #[bean(option)] fn build_goo_some() -> Option { Some(Goo { list: vec!["hello".to_string()] }) } #[allow(dead_code)] struct Foo { pub list: Vec, } #[bean(option, lazy)] fn build_foo() -> Option { Some(Foo { list: vec!["world".to_string()] }) } #[test] fn option() { setup_submitted_beans(); assert!(!autowired::exist_component::()); assert!(autowired::exist_component::()); assert!(!autowired::exist_component::()); let goo = Autowired::::new(); assert_eq!("hello", goo.list[0]); let foo = Autowired::::new(); assert_eq!("world", foo.list[0]); assert!(!autowired::exist_component::()); assert!(autowired::exist_component::()); assert!(autowired::exist_component::()); }