aboutsummaryrefslogtreecommitdiff
path: root/examples/generics/main.rs
blob: 7910cad8e0af74814530670820e4755f2804b54e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
mod bootstrap;
mod interfaces;
mod printer;

use std::error::Error;

use syrette::di_container::blocking::prelude::*;

use crate::bootstrap::bootstrap;
use crate::interfaces::printer::IPrinter;

fn main() -> Result<(), Box<dyn Error>>
{
    let di_container = bootstrap();

    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>>()?.transient()?;

    int_printer.print(2782028);

    Ok(())
}