Skip to content

Commit

Permalink
Update documentation of source-backtrace behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Aug 28, 2021
1 parent 799bb53 commit 71c7ebe
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,14 @@ pub enum DataStoreError {
}
```

- If a field is `#[from]` and `#[backtrace]`, the Error trait's `backtrace()`
method is forwarded to the `source`.
- If a field is both a source (named `source`, or has `#[source]` or `#[from]`
attribute) *and* is marked `#[backtrace]`, then the Error trait's
`backtrace()` method is forwarded to the source's backtrace.

```rust
#[derive(Error, Debug)]
pub enum MyError {
Io {
#[from]
#[backtrace]
source: io::Error,
},
Expand Down
6 changes: 3 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,15 +161,15 @@
//! # };
//! ```
//!
//! - If a field is `#[from]` and `#[backtrace]`, the Error trait's
//! `backtrace()` method is forwarded to the field.
//! - If a field is both a source (named `source`, or has `#[source]` or
//! `#[from]` attribute) *and* is marked `#[backtrace]`, then the Error
//! trait's `backtrace()` method is forwarded to the source's backtrace.
//!
//! ```rust
//! # const IGNORE: &str = stringify! {
//! #[derive(Error, Debug)]
//! pub enum MyError {
//! Io {
//! #[from]
//! #[backtrace]
//! source: io::Error,
//! },
Expand Down

0 comments on commit 71c7ebe

Please sign in to comment.