Skip to content
Myr

Omit '0:' if only one cause

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 ad275d5 · Browse files · 4 files+9 added−6 removed
This commit

State

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

Diff stats

4 files+9 added−6 removed

  • other:+9 added−6 removed

4 files+9 added−6 removed

modified:src/context.rs+1 added-1 removed
43 unmodified lines
44/// ```console45/// Error: failed to read instrs from ./path/to/instrs.jsox46///47/// caused by:48/// 0: No such file or directory (os error 2)48/// No such file or directory (os error 2)49/// ```50pub trait Context<T, E> {51 /// Wrap the error value with additional context.52 fn context<C>(self, context: C) -> Result<T, Error>
105 unmodified lines
modified:src/error.rs+6 added-3 removed
314 unmodified lines
315impl Debug for Error {316 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {317 writeln!(f, "{}", self.inner.error())?;318319 let mut chain = self.chain().skip(1).enumerate();319 let mut chain = self.chain().skip(1).enumerate().peekable();320 if let Some((n, error)) = chain.next() {321 writeln!(f, "\nCaused by:")?;322 writeln!(f, " {}: {}", n, error)?;321 write!(f, "\nCaused by:\n ")?;322 if chain.peek().is_some() {323 write!(f, "{}: ", n)?;324 }325 writeln!(f, "{}", error)?;326 for (n, error) in chain {327 writeln!(f, " {}: {}", n, error)?;328 }329 }
182 unmodified lines
modified:src/lib.rs+1 added-1 removed
79 unmodified lines
80//! ```console81//! Error: failed to read instrs from ./path/to/instrs.jsox82//!83//! Caused by:84//! 0: No such file or directory (os error 2)84//! No such file or directory (os error 2)85//! ```86//!87//! - Downcasting is supported and can be by value, by shared reference, or by88//! mutable reference as needed.
259 unmodified lines
modified:README.md+1 added-1 removed