8000 Add Display impl for AugmentedScriptSet · thomcc/unicode-security@da19f75 · GitHub
[go: up one dir, main page]

8000 Skip to content

Commit da19f75

Browse files
committed
Add Display impl for AugmentedScriptSet
1 parent 7ea5530 commit da19f75

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

src/mixed_script.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,36 @@ impl Debug for AugmentedScriptSet {
105105
}
106106
}
107107

108+
impl fmt::Display for AugmentedScriptSet {
109+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
110+
if self.is_empty() {
111+
write!(f, "Empty")?;
112+
} else if self.is_all() {
113+
write!(f, "All")?;
114+
} else {
115+
let mut first_entry = true;
116+
let hanb = if self.hanb { Some("Han with Bopomofo") } else { None };
117+
let jpan = if self.jpan { Some("Japanese") } else { None };
118+
let kore = if self.kore { Some("Krorean") } else { None };
119+
for writing_system in None
120+
.into_iter()
121+
.chain(hanb)
122+
.chain(jpan)
123+
.chain(kore)
124+
.chain(self.base.iter().map(Script::full_name))
125+
{
126+
if !first_entry {
127+
write!(f, ", ")?;
128+
} else {
129+
first_entry = false;
130+
}
131+
write!(f, "{}", writing_system)?;
132+
}
133+
}
134+
Ok(())
135+
}
136+
}
137+
108138
impl AugmentedScriptSet {
109139
/// Intersect this set with another
110140
pub fn intersect_with(&mut self, other: Self) {

0 commit comments

Comments
 (0)
0