blob: 2069f1479c08fb865a43b95d83d8fbc6243d18c5 (
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
use syrette::injectable;
use syrette::ptr::TransientPtr;
use crate::interfaces::ninja::INinja;
use crate::interfaces::weapon::IWeapon;
pub struct Ninja
{
strong_weapon: TransientPtr<dyn IWeapon>,
weak_weapon: TransientPtr<dyn IWeapon>,
}
#[injectable(INinja)]
impl Ninja
{
pub fn new(
#[rustfmt::skip] // Prevent rustfmt from turning this into a single line
#[syrette::named("strong")]
strong_weapon: TransientPtr<dyn IWeapon>,
#[rustfmt::skip] // Prevent rustfmt from turning this into a single line
#[named("weak")]
weak_weapon: TransientPtr<dyn IWeapon>,
) -> Self
{
Self {
strong_weapon,
weak_weapon,
}
}
}
impl INinja for Ninja
{
fn use_weapons(&self)
{
println!("Ninja is using his strong weapon!");
self.strong_weapon.use_it();
println!("Ninja is using his weak weapon!");
self.weak_weapon.use_it();
}
}
|