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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
#![deny(clippy::all)]
#![deny(clippy::pedantic)]
#![allow(clippy::module_name_repetitions)]
mod bootstrap;
mod interfaces;
mod user;
use bootstrap::bootstrap;
use interfaces::user::IUser;
use interfaces::user::IUserFactory;
use syrette::ptr::FactoryPtr;
use syrette::ptr::InterfacePtr;
fn add_users(
users: &mut Vec<InterfacePtr<dyn IUser>>,
user_factory: &FactoryPtr<IUserFactory>,
)
{
users.push(user_factory("Bob", "1983-04-13", "abc1234"));
users.push(user_factory("Anna", "1998-01-20", "IlovemYCat"));
users.push(user_factory("David", "2000-11-05", "12345678"));
}
fn main()
{
println!("Hello, world!");
let di_container = bootstrap();
let user_factory = di_container.get_factory::<IUserFactory>().unwrap();
let mut users = Vec::<InterfacePtr<dyn IUser>>::new();
add_users(&mut users, &user_factory);
println!("Printing user information");
for user in users {
println!(
"{}, born {}, password is '{}'",
user.get_name(),
user.get_date_of_birth(),
user.get_password()
);
}
}
|