Skip to content
Myr

Remove verbose Indented constructors

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by David Tolnay · committed by David Tolnay · parent ba0f8c9 · Browse files · 1 file+8 added−29 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+8 added−29 removed

  • other:+8 added−29 removed

1 file+8 added−29 removed

modified:src/fmt.rs+8 added-29 removed
27 unmodified lines
28 write!(f, "\n\nCaused by:")?;29 let multiple = cause.source().is_some();30 for (n, error) in Chain::new(cause).enumerate() {31 writeln!(f)?;32 write!(33 if multiple {34 Indented::numbered(f, n)35 } else {36 Indented::new(f)37 },38 "{}",39 error40 )?;32 let mut indented = Indented {33 inner: f,34 ind: if multiple { Some(n) } else { None },35 started: false,36 };37 write!(indented, "{}", error)?;38 }39 }4041 #[cfg(backtrace)]
21 unmodified lines
63 ind: Option<usize>,64 started: bool,65}6670impl<'a, D> Indented<'a, D> {71 fn numbered(inner: &'a mut D, ind: usize) -> Self {72 Self {73 inner,74 ind: Some(ind),75 started: false,76 }77 }7879 fn new(inner: &'a mut D) -> Self {80 Self {81 inner,82 ind: None,83 started: false,84 }85 }86}8788impl<T> fmt::Write for Indented<'_, T>67impl<T> Write for Indented<'_, T>68where90 T: fmt::Write,69 T: Write,70{71 fn write_str(&mut self, s: &str) -> fmt::Result {72 for (ind, mut line) in s.split('\n').enumerate() {73 if !self.started {
83 unmodified lines