blob: d3c0b17424b94cfea7e3592d7c4f1d5bdecab7ee (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
use std::collections::HashMap;
#[derive(Debug, PartialEq, Eq, Clone, Hash)]
pub struct RoomId {
pub name: String
}
impl RoomId {
pub fn from_str(name: &str) -> Self {
Self {name: name.to_string()}
}
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}
}
}
|