aboutsummaryrefslogtreecommitdiff
path: root/src/who.rs
blob: 8e167652eb13dc75eb6e35a524c2c3348d581e09 (plain) (blame)
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
use serde::{Deserialize, Serialize};

#[derive(Debug, Default, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
pub struct Who {
    name: String,
}

impl std::ops::Deref for Who {
    type Target = String;

    fn deref(&self) -> &Self::Target {
        &self.name
    }
}

impl std::ops::DerefMut for Who {
    fn deref_mut(&mut self) -> &mut Self::Target {
        &mut self.name
    }
}

impl From<String> for Who {
    fn from(s: String) -> Self {
        Who { name: s }
    }
}

impl From<&str> for Who {
    fn from(s: &str) -> Self {
        Who {
            name: s.to_string(),
        }
    }
}

impl From<Who> for String {
    fn from(val: Who) -> Self {
        val.name
    }
}

impl std::fmt::Display for Who {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        write!(f, "{}", self.name)
    }
}