Allow result.into() to work for transforming return result errors
Nobody has claimed this yet.
- Dominant language
- Markdown
- Stars
- 6.6k
- Forks
- 1.7k
- Avg merge
- 16h 14m
- Merged PRs (30d)
- 1
Description
Currently, I have multiple places in my codebase where I end up doing Ok(try!(myres)) in order to get the error type to convert cleanly. It would be nice to have something like:
impl From<Result<T, E1>> for Result<T, E2>
where E1: Into<E2>
{
fn from(res: Result<T, E1>) -> Self {
match res {
Ok(t) => Ok(t),
Err(e) => Err(e.into()),
}
}
}
Not sure if it should also use an .into() call on T to support a T2 or not.
Thoughts?
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.
Research direction
No file, test, or entry point is named. Start by reviewing the proposed Result and From implementations and the surrounding discussion, then determine whether conversion should apply only to errors or also to values; done means an agreed design and corresponding RFC or implementation plan.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 20/100