aboutsummaryrefslogtreecommitdiffstats
path: root/mumlib/src/state.rs
diff options
context:
space:
mode:
authorEskil <eskilq@kth.se>2020-11-06 22:00:24 +0100
committerEskil <eskilq@kth.se>2020-11-06 22:00:24 +0100
commit1b3bcebc895bfa4b6f65697fafc31d482c74b2de (patch)
tree8f3e8fa198747aa260128951eccd54994ca1fdb5 /mumlib/src/state.rs
parentd6496cb0f6abba855b04338fa8bc5aaa89487c29 (diff)
parent0220f0372937ed179aa84fa6e2250933cd3e3896 (diff)
downloadmum-1b3bcebc895bfa4b6f65697fafc31d482c74b2de.tar.gz
Merge branch 'mute' into 'main'
Mute Closes #43 See merge request gustav/mum!29
Diffstat (limited to 'mumlib/src/state.rs')
-rw-r--r--mumlib/src/state.rs21
1 files changed, 20 insertions, 1 deletions
diff --git a/mumlib/src/state.rs b/mumlib/src/state.rs
index b6b4039..3b1da56 100644
--- a/mumlib/src/state.rs
+++ b/mumlib/src/state.rs
@@ -130,9 +130,28 @@ pub struct User {
pub deaf: bool, // by admin
}
+macro_rules! true_to_str {
+ ($condition:expr, $res:expr) => {
+ if $condition {
+ $res
+ } else {
+ ""
+ }
+ };
+}
+
impl Display for User {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
- write!(f, "{}", self.name)
+ write!(
+ f,
+ "{} {}{}{}{}{}",
+ self.name,
+ true_to_str!(self.suppress, "s"),
+ true_to_str!(self.self_mute, "M"),
+ true_to_str!(self.self_deaf, "D"),
+ true_to_str!(self.mute, "m"),
+ true_to_str!(self.deaf, "d")
+ )
}
}