aboutsummaryrefslogtreecommitdiff
path: root/examples/generics
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2022-08-25 20:21:49 +0200
committerHampusM <hampus@hampusmat.com>2022-08-27 14:28:23 +0200
commit1c46b68581213ca8ae6200daa32f626b5389b4b0 (patch)
tree8da649471db7893a2347a2df383324b84ac226f0 /examples/generics
parent8e862c7998d0b59c71d20cbcbbc57031f734b6fa (diff)
refactor!: make DI container have single get function
BREAKING CHANGE: The DI container get_singleton & get_factory functions have been replaced by the get function now returning a enum
Diffstat (limited to 'examples/generics')
-rw-r--r--examples/generics/main.rs10
1 files changed, 7 insertions, 3 deletions
diff --git a/examples/generics/main.rs b/examples/generics/main.rs
index 9442641..f491aa0 100644
--- a/examples/generics/main.rs
+++ b/examples/generics/main.rs
@@ -2,18 +2,22 @@ mod bootstrap;
mod interfaces;
mod printer;
+use std::error::Error;
+
use bootstrap::bootstrap;
use interfaces::printer::IPrinter;
-fn main()
+fn main() -> Result<(), Box<dyn Error>>
{
let di_container = bootstrap();
- let string_printer = di_container.get::<dyn IPrinter<String>>().unwrap();
+ let string_printer = di_container.get::<dyn IPrinter<String>>()?.transient()?;
string_printer.print("Hello there".to_string());
- let int_printer = di_container.get::<dyn IPrinter<i32>>().unwrap();
+ let int_printer = di_container.get::<dyn IPrinter<i32>>()?.transient()?;
int_printer.print(2782028);
+
+ Ok(())
}