diff --git a/Cargo.toml b/Cargo.toml index 3bac3ee..668f5a0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,3 +21,6 @@ github = { repository = "haraldh/chainerror", workflow = "Rust" } maintenance = { status = "actively-developed" } is-it-maintained-issue-resolution = { repository = "haraldh/chainerror" } is-it-maintained-open-issues = { repository = "haraldh/chainerror" } + +[package.metadata.docs.rs] +cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"] diff --git a/README.md b/README.md index 7a7b3a9..7df21e4 100644 --- a/README.md +++ b/README.md @@ -84,7 +84,7 @@ Os { code: 2, kind: NotFound, message: "No such file or directory" } `chainerror` uses `.source()` of `std::error::Error` along with `#[track_caller]` and `Location` to provide a nice debug error backtrace. It encapsulates all types, which have `Display + Debug` and can store the error cause internally. -Along with the `ChainError` struct, `chainerror` comes with some useful helper macros to save a lot of typing. +Along with the `Error` struct, `chainerror` comes with some useful helper macros to save a lot of typing. `chainerror` has no dependencies! @@ -98,8 +98,8 @@ Read the [Tutorial](https://haraldh.github.io/chainerror/tutorial1.html) Licensed under either of -* Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or https://www.apache.org/licenses/LICENSE-2.0) -* MIT license ([LICENSE-MIT](LICENSE-MIT) or https://opensource.org/licenses/MIT) +* Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or ) +* MIT license ([LICENSE-MIT](LICENSE-MIT) or ) at your option. diff --git a/src/lib.rs b/src/lib.rs index 50dbd51..1b6039c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -100,9 +100,9 @@ impl Error { .next() } - /// Find the first error cause of type `ChainError`, if any exists + /// Find the first error cause of type [`Error`](Error), if any exists /// - /// Same as `find_cause`, but hides the `ChainError` implementation internals + /// Same as `find_cause`, but hides the [`Error`](Error) implementation internals /// /// # Examples /// @@ -123,9 +123,9 @@ impl Error { .next() } - /// Find the first error cause of type `ChainError` or `U`, if any exists and return `U` + /// Find the first error cause of type [`Error`](Error) or `U`, if any exists and return `U` /// - /// Same as `find_cause` and `find_chain_cause`, but hides the `ChainError` implementation internals + /// Same as `find_cause` and `find_chain_cause`, but hides the [`Error`](Error) implementation internals /// /// # Examples /// @@ -154,7 +154,7 @@ impl Error { .next() } - /// Return a reference to T of `ChainError` + /// Return a reference to T of [`Error`](Error) /// /// # Examples /// @@ -224,7 +224,7 @@ impl Error { } } -/// Convenience methods for `Result<>` to turn the error into a decorated ChainError +/// Convenience methods for `Result<>` to turn the error into a decorated [`Error`](Error) pub trait ResultTrait>> { /// Decorate the error with a `kind` of type `T` and the source `Location` fn context(self, kind: T) -> std::result::Result>; @@ -297,17 +297,17 @@ impl std::ops::Deref for Error { } } -/// Convenience trait to hide the `ChainError` implementation internals +/// Convenience trait to hide the [`Error`](Error) implementation internals pub trait ChainErrorDown { - /// Test if of type `ChainError` + /// Test if of type `Error` fn is_chain(&self) -> bool; - /// Downcast to a reference of `ChainError` + /// Downcast to a reference of `Error` fn downcast_chain_ref(&self) -> Option<&Error>; - /// Downcast to a mutable reference of `ChainError` + /// Downcast to a mutable reference of `Error` fn downcast_chain_mut(&mut self) -> Option<&mut Error>; - /// Downcast to T of `ChainError` + /// Downcast to T of `Error` fn downcast_inner_ref(&self) -> Option<&T>; - /// Downcast to T mutable reference of `ChainError` + /// Downcast to T mutable reference of `Error` fn downcast_inner_mut(&mut self) -> Option<&mut T>; } @@ -505,7 +505,7 @@ impl Debug for Error { #[inline] fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { if f.alternate() { - let mut f = f.debug_struct(&format!("ChainError<{}>", std::any::type_name::())); + let mut f = f.debug_struct(&format!("Error<{}>", std::any::type_name::())); let f = f .field("occurrence", &self.occurrence) @@ -601,9 +601,9 @@ macro_rules! derive_str_context { }; } -/// Derive an Error for an ErrorKind, which wraps a `ChainError` and implements a `kind()` method +/// Derive an Error for an ErrorKind, which wraps a [`Error`](Error) and implements a `kind()` method /// -/// It basically hides `ChainError` to the outside and only exposes the `kind()` +/// It basically hides [`Error`](Error) to the outside and only exposes the [`kind()`](Error::kind) /// method. /// /// Error::kind() returns the ErrorKind @@ -682,7 +682,7 @@ macro_rules! derive_err_kind { } } - impl From> for $e { + impl From<$crate::Error<$k>> for $e { fn from(e: $crate::Error<$k>) -> Self { $e(e) }