stacks-network / stacks-network/stacks-core
Add function to discard error from `result` and return `optional`
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 3.1k
- Forks
- 762
- Avg merge
- 4d 6h
- Merged PRs (30d)
- 76
Description
It would be nice to have the equivalent of Rust's Result::ok(), which discards the error from a Result and return an Option
Currently, to do this you would have to write:
(match (some-parsing-function bytes)
ok (some ok)
err none)
Consistent with the syntax I've proposed here for other type conversion functions, I propose adding to-optional to convert result types into optional types:
(to-optional (some-parsing-function bytes))
Contributor guide
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
Start by locating the code that defines or exposes Clarity Result and Option conversions; the issue provides no file or test entry point. Compare the proposed to-optional behavior with the existing match example and the linked conversion syntax discussion. Done means a Result value can discard its error and return the corresponding Option value.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- blockchain
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100