blob: 48bf095b1fa8a195cdabc9c001b61df9daac978e (
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
47
48
49
50
51
52
53
54
55
56
57
|
/// Provides a description for any Grouped type.
pub struct Description {
desc: String,
}
impl Description {
/// Creates a new `Description` instance.
pub fn new<S: Into<String>>(desc: S) -> Self {
Self { desc: desc.into() }
}
}
impl From<String> for Description {
fn from(desc: String) -> Self {
Self { desc }
}
}
impl From<&str> for Description {
fn from(desc: &str) -> Self {
Self {
desc: desc.to_string(),
}
}
}
impl From<Description> for String {
fn from(desc: Description) -> Self {
desc.desc
}
}
impl From<&Description> for String {
fn from(desc: &Description) -> Self {
desc.desc.clone()
}
}
impl std::ops::Deref for Description {
type Target = str;
fn deref(&self) -> &Self::Target {
&self.desc
}
}
impl std::ops::DerefMut for Description {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.desc
}
}
impl std::fmt::Display for Description {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.desc)
}
}
|