summaryrefslogtreecommitdiff
path: root/src/roomid.rs
diff options
context:
space:
mode:
authortroido <troido@protonmail.com>2020-04-03 23:25:20 +0200
committertroido <troido@protonmail.com>2020-04-03 23:25:20 +0200
commit0b17829846adf9482b460e4cc616382ede1df6dd (patch)
tree2f02dd93b1cd4cd7615341644ddeb94ed0dfc422 /src/roomid.rs
parentdb473bbab28847bed5f26fb443ef8a1db2d932a3 (diff)
private rooms work!
Diffstat (limited to 'src/roomid.rs')
-rw-r--r--src/roomid.rs6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/roomid.rs b/src/roomid.rs
index 1f356fa..d3c0b17 100644
--- a/src/roomid.rs
+++ b/src/roomid.rs
@@ -1,4 +1,6 @@
+use std::collections::HashMap;
+
#[derive(Debug, PartialEq, Eq, Clone, Hash)]
pub struct RoomId {
pub name: String
@@ -11,5 +13,9 @@ impl RoomId {
pub fn to_string(&self) -> String {
self.name.clone()
}
+ pub fn format(&self, dict: HashMap<&str, &str>) -> Self {
+ let name = dict.into_iter().fold(self.name.clone(), |name, (from, to)| name.replace(from, to));
+ Self {name}
+ }
}