| 50 | } |
| 51 | |
| 52 | pub fn markdown(&self) -> String { |
| 53 | fn quote(name: &String) -> String { |
| 54 | format!("\"{name}\"") |
| 55 | } |
| 56 | |
| 57 | match self.len() { |
| 58 | 0 => "[missing synonym]".to_owned(), |
| 59 | 1 => self.0.values().map(quote).join(""), |
| 60 | |
| 61 | 2 => self.0.values().map(quote).join(" and "), |
| 62 | |
| 63 | 3 => { |
| 64 | let mut result = String::new(); |
| 65 | |
| 66 | for (i, (_locale, name)) in self.0.iter().enumerate() { |
| 67 | match i { |
| 68 | 0 => { |
| 69 | result.push_str("e(name)); |
| 70 | result.push_str(", "); |
| 71 | } |
| 72 | 1 => { |
| 73 | result.push_str("e(name)); |
| 74 | result.push_str(" and "); |
| 75 | } |
| 76 | 2 => { |
| 77 | result.push_str("e(name)); |
| 78 | } |
| 79 | _ => unreachable!("unexpected index"), |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | result |
| 84 | } |
| 85 | |
| 86 | _ => "several synonyms".to_owned(), |
| 87 | } |
| 88 | } |
| 89 | |
| 90 | pub fn len(&self) -> usize { |
| 91 | self.0.len() |