-
Notifications
You must be signed in to change notification settings - Fork 533
/
Copy pathverbosity.rs
44 lines (37 loc) · 828 Bytes
/
verbosity.rs
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
#[allow(clippy::arbitrary_source_item_ordering)]
#[derive(Copy, Clone, Debug, PartialEq, PartialOrd)]
pub(crate) enum Verbosity {
Quiet,
Taciturn,
Loquacious,
Grandiloquent,
}
impl Verbosity {
pub(crate) fn from_flag_occurrences(flag_occurrences: u8) -> Self {
match flag_occurrences {
0 => Self::Taciturn,
1 => Self::Loquacious,
_ => Self::Grandiloquent,
}
}
pub(crate) fn quiet(self) -> bool {
self == Self::Quiet
}
pub(crate) fn loud(self) -> bool {
!self.quiet()
}
pub(crate) fn loquacious(self) -> bool {
self >= Self::Loquacious
}
pub(crate) fn grandiloquent(self) -> bool {
self >= Self::Grandiloquent
}
pub const fn default() -> Self {
Self::Taciturn
}
}
impl Default for Verbosity {
fn default() -> Self {
Self::default()
}
}