Improve #[from] documentation example.
- 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.