From 0b17829846adf9482b460e4cc616382ede1df6dd Mon Sep 17 00:00:00 2001 From: troido Date: Fri, 3 Apr 2020 23:25:20 +0200 Subject: private rooms work! --- src/roomid.rs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/roomid.rs') 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} + } } -- cgit