Skip to content

Commit fe18fa6

Browse files
committed
Fixes for debug formatting
* Debug now prints full values for the internal representation, which is more helpful when combined with a hex or binary printing mode. * Display now properly renders all the scripts with " + " seperators.
1 parent 1f84c2e commit fe18fa6

File tree

1 file changed

+8
-18
lines changed

1 file changed

+8
-18
lines changed

src/lib.rs

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ impl fmt::Display for Script {
131131
}
132132
}
133133

134-
#[derive(Clone, Copy, PartialEq, Eq, Hash)]
134+
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
135135
#[non_exhaustive]
136136
/// A value for the `Script_Extension` property
137137
///
@@ -311,33 +311,23 @@ impl From<&'_ str> for ScriptExtension {
311311
}
312312
}
313313

314-
impl fmt::Debug for ScriptExtension {
315-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
316-
write!(f, "ScriptExtension(")?;
317-
fmt::Display::fmt(self, f)?;
318-
write!(f, ")")
319-
}
320-
}
321-
322314
impl fmt::Display for ScriptExtension {
323315
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
324-
if self.is_common() {
325-
write!(f, "Common")?;
326-
} else if self.is_inherited() {
327-
write!(f, "Inherited")?;
328-
} else if self.is_empty() {
316+
write!(f, "ScriptExtension(")?;
317+
if self.is_empty() {
329318
write!(f, "Unknown")?;
330319
} else {
331320
let mut first = true;
332321
for script in self.iter() {
333-
if !first {
334-
write!(f, " + ")?;
322+
if first {
335323
first = false;
324+
} else {
325+
write!(f, " + ")?;
336326
}
337327
script.full_name().fmt(f)?;
338328
}
339329
}
340-
Ok(())
330+
write!(f, ")")
341331
}
342332
}
343333

@@ -361,7 +351,7 @@ impl UnicodeScript for char {
361351

362352
/// Iterator over scripts in a [ScriptExtension].
363353
///
364-
/// Can be obtained ia [ScriptExtension::iter()]
354+
/// Can be obtained via [ScriptExtension::iter()]
365355
pub struct ScriptIterator {
366356
ext: ScriptExtension,
367357
}

0 commit comments

Comments
 (0)