Add LimitedDisplay

This commit is contained in:
Shunsuke Shibayama 2022-08-24 18:51:12 +09:00
parent 7633618e76
commit 0ebb0ce94c
6 changed files with 278 additions and 107 deletions

View file

@ -420,8 +420,10 @@ pub struct NormalArray {
}
impl NestedDisplay for NormalArray {
fn fmt_nest(&self, f: &mut fmt::Formatter<'_>, _level: usize) -> fmt::Result {
write!(f, "[{}]", self.elems)
fn fmt_nest(&self, f: &mut fmt::Formatter<'_>, level: usize) -> fmt::Result {
writeln!(f, "[")?;
self.elems.fmt_nest(f, level + 1)?;
write!(f, "\n{}]", " ".repeat(level))
}
}