From ed2d73ed81da2f6b6784796a1751335c4fa46816 Mon Sep 17 00:00:00 2001 From: HampusM Date: Sun, 28 Aug 2022 11:34:18 +0200 Subject: docs: correct the example in the readme --- README.md | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 22db44a..04f2ca4 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,8 @@ The goal of Syrette is to be a simple, useful, convenient and familiar DI librar ## Example usage ```rust +use std::error::Error; + use syrette::{injectable, DIContainer}; use syrette::ptr::TransientPtr; @@ -70,7 +72,8 @@ trait IWarrior fn fight(&self); } -struct Warrior { +struct Warrior +{ weapon: TransientPtr, } @@ -91,19 +94,21 @@ impl IWarrior for Warrior } } -fn main() +fn main() -> Result<(), Box> { let mut di_container = DIContainer::new(); - di_container.bind::().to::().unwrap(); + di_container.bind::().to::()?; - di_container.bind::().to::().unwrap(); + di_container.bind::().to::()?; - let warrior = di_container.get::().unwrap(); + let warrior = di_container.get::()?.transient()?; warrior.fight(); println!("Warrior has fighted"); + + Ok(()) } ``` -- cgit v1.2.3-18-g5258