aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2022-08-03 14:40:42 +0200
committerHampusM <hampus@hampusmat.com>2022-08-21 18:17:50 +0200
commitcc4a5081e259ed798613175d116a34162bc657fa (patch)
treec3403054d5b277d904fb504336a512bfbf0f498f
parentb28ebe3007afbe3c581eb54df4c0baa26a9f508f (diff)
docs: correct examples
-rw-r--r--README.md4
-rw-r--r--src/di_container.rs10
2 files changed, 9 insertions, 5 deletions
diff --git a/README.md b/README.md
index 50dc5ac..5ff2d88 100644
--- a/README.md
+++ b/README.md
@@ -92,9 +92,9 @@ fn main()
{
let mut di_container = DIContainer::new();
- di_container.bind::<dyn IWeapon>().to::<Sword>();
+ di_container.bind::<dyn IWeapon>().to::<Sword>().unwrap();
- di_container.bind::<dyn IWarrior>().to::<Warrior>();
+ di_container.bind::<dyn IWarrior>().to::<Warrior>().unwrap();
let warrior = di_container.get::<dyn IWarrior>().unwrap();
diff --git a/src/di_container.rs b/src/di_container.rs
index 239a2cb..eaa0366 100644
--- a/src/di_container.rs
+++ b/src/di_container.rs
@@ -32,13 +32,17 @@
//! }
//! }
//!
-//! fn main() -> error_stack::Result<(), DIContainerError>
+//! fn main() -> Result<(), String>
//! {
//! let mut di_container = DIContainer::new();
//!
-//! di_container.bind::<dyn IDatabaseService>().to::<DatabaseService>();
+//! di_container.bind::<dyn IDatabaseService>().to::<DatabaseService>().map_err(|err| {
+//! err.to_string()
+//! })?;
//!
-//! let database_service = di_container.get::<dyn IDatabaseService>()?;
+//! let database_service = di_container.get::<dyn IDatabaseService>().map_err(|err| {
+//! err.to_string()
+//! })?;
//!
//! Ok(())
//! }