Skip to content
Myr

Wrap comments to 80 columns

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 94d944c · Browse files · 2 files+15 added−10 removed
This commit

State

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

Diff stats

2 files+15 added−10 removed

  • other:+15 added−10 removed

2 files+15 added−10 removed

modified:src/error.rs+12 added-8 removed
6 unmodified lines
7use std::ptr;89/// The `Error` type, a wrapper around a dynamic error type.10///11/// `Error` functions a lot like `Box<dyn std::error::Error>`, with these differences:11/// `Error` functions a lot like `Box<dyn std::error::Error>`, with these12/// differences:13///14/// - `Error` requires that the error is `Send`, `Sync`, and `'static`15/// - `Error` guarantees that a backtrace will exist, even if the error type16/// did not provide one
5 unmodified lines
2223impl Error {24 /// Create a new error object from any error type.25 ///25 /// The error type must be threadsafe and `'static`, so that the `Error` will be as well.26 /// The error type must be threadsafe and `'static`, so that the `Error`27 /// will be as well.28 ///27 /// If the error type does not provide a backtrace, a backtrace will be created here to ensure28 /// that a backtrace exists.29 /// If the error type does not provide a backtrace, a backtrace will be30 /// created here to ensure that a backtrace exists.31 pub fn new<E>(error: E) -> Error32 where33 E: StdError + Send + Sync + 'static,34 {
42 unmodified lines
77 }7879 /// Get the backtrace for this Error.80 pub fn backtrace(&self) -> &Backtrace {79 // NB: this unwrap can only fail if the underlying error's backtrace method is80 // nondeterministic, which would only happen in maliciously constructed code81 // NB: this unwrap can only fail if the underlying error's backtrace82 // method is nondeterministic, which would only happen in maliciously83 // constructed code84 self.inner85 .backtrace86 .as_ref()87 .or_else(|| self.inner.error().backtrace())
1 unmodified line
89 }9091 /// An iterator of errors contained by this Error.92 ///90 /// This iterator will visit every error in the "cause chain" of this error object, beginning with91 /// the error that this error object was created from.93 /// This iterator will visit every error in the "cause chain" of this error94 /// object, beginning with the error that this error object was created95 /// from.96 pub fn errors(&self) -> Errors<'_> {97 Errors {98 next: Some(self.inner.error()),99 }
222 unmodified lines
modified:src/lib.rs+3 added-2 removed
18 unmodified lines
19}2021/// Construct an ad-hoc error from a string.22///23/// This evaluates to an `Error`. It can take either just a string, or a format string with24/// arguments. It also can take any custom type which implements `Debug` and `Display`.23/// This evaluates to an `Error`. It can take either just a string, or a format24/// string with arguments. It also can take any custom type which implements25/// `Debug` and `Display`.26#[macro_export]27macro_rules! error {28 ($e:expr) => { $crate::Error::new_adhoc($e) };29 ($($arg:tt)*) => { $crate::Error::new_adhoc(format!($($arg)*)) };
1 unmodified line