Returns a dot-separated human-readable representation of this name.
(&self)
| 235 | |
| 236 | /// Returns a dot-separated human-readable representation of this name. |
| 237 | pub fn pretty(&self) -> String { |
| 238 | let mut components = Vec::new(); |
| 239 | let mut current = self; |
| 240 | |
| 241 | loop { |
| 242 | match current.as_data() { |
| 243 | NameData::Anonymous(_) => break, |
| 244 | NameData::Str(pre, s, _) => { |
| 245 | components.push(s.as_str().to_owned()); |
| 246 | current = pre; |
| 247 | }, |
| 248 | NameData::Num(pre, n, _) => { |
| 249 | components.push(n.0.to_string()); |
| 250 | current = pre; |
| 251 | }, |
| 252 | } |
| 253 | } |
| 254 | |
| 255 | components.reverse(); |
| 256 | components.join(".") |
| 257 | } |
| 258 | } |
| 259 | |
| 260 | impl StdHash for Name { |