Improve #[from] documentation example.
Nobody has claimed this yet.
Assessment
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Newbie friendliness
- 62/100
- Issue type
- Documentation
- Clarity
- Clearly specified
- Activity status
- Stale
- Tech stack
- rust
- Domain
- documentation
Research direction
Start by reading the library documentation examples for the #[from] attribute, especially the tuple and struct-field forms shown in the issue. Update the documentation to demonstrate displaying the derived io::Error message, and consider the work done when the example makes that behavior clear.
Written by the indexing model from the issue text.
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.
#[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.
#[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!
- Dominant language
- Rust
- Stars
- 5.5k
- Forks
- 214
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from dtolnay/thiserror
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
-
Difficulty 5/5 Over a week Newbie friendliness 30/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 45/100
All issues in dtolnay/thiserror
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Eynzof/Hermes-CN-Desktop#610 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
gitbutlerapp/gitbutler#15998 · 1 comment ·
-
bug triage:deciding
Difficulty 1/5 Under an hour Newbie friendliness 88/100
open-telemetry/otel-arrow#4132 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100