dtolnay / dtolnay/thiserror

Improve #[from] documentation example.

Open
#135 4 comments 8 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
5.5k
Forks
213
PR merge metrics
No merged PRs in 30d

Description

Hey folks,

There is an issue that took me a while to understand, and it's that in the lib doc is not very clear how to display the error that is being derived with `#[from]` macro.

The actual example is e.g.

```Rust
#[error("data store disconnected")]
Disconnect(#[from] io::Error)
```

Despite there is also an example of how to use from attribute over a struct field e.g.

```Rust
#[derive(Error, Debug)]
pub enum MyError {
Io {
#[from]
source: io::Error,
backtrace: Backtrace,
},
}
```

None of these examples tells you can do it e.g.

```
#[error("data store disconnected: {0}")]
Disconnect(#[from] io::Error)
```

Would be great to have it in the doc.

Thanks!

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.