diff options
| author | troido <troido@protonmail.com> | 2020-04-03 23:25:20 +0200 |
|---|---|---|
| committer | troido <troido@protonmail.com> | 2020-04-03 23:25:20 +0200 |
| commit | 0b17829846adf9482b460e4cc616382ede1df6dd (patch) | |
| tree | 2f02dd93b1cd4cd7615341644ddeb94ed0dfc422 /src/roomid.rs | |
| parent | db473bbab28847bed5f26fb443ef8a1db2d932a3 (diff) | |
private rooms work!
Diffstat (limited to 'src/roomid.rs')
| -rw-r--r-- | src/roomid.rs | 6 |
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} + } } |
