1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
//! # Name - Trait Implementations
//!
//! This module contains trait implementations for `Name`.
//!
//! ## Implemented Traits
//!
//! - `Display`
//! - `PartialOrd`
//! - `Ord`
//!
//! 🤖 Generated with [SplitRS](https://github.com/cool-japan/splitrs)
use super::types::Name;
impl std::fmt::Display for Name {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Name::Anonymous => write!(f, "_"),
Name::Str(parent, s) => {
if parent.is_anonymous() {
write!(f, "{s}")
} else {
write!(f, "{parent}.{s}")
}
}
Name::Num(parent, n) => {
if parent.is_anonymous() {
write!(f, "{n}")
} else {
write!(f, "{parent}.{n}")
}
}
}
}
}
impl PartialOrd for Name {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
Some(self.cmp(other))
}
}
impl Ord for Name {
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
self.to_string().cmp(&other.to_string())
}
}