Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds collect methods for arrays of results and maybes #46
Adds collect methods for arrays of results and maybes #46
Changes from 13 commits
9686006
66f0f29
4568bfd
ded146d
0c572f2
d9e987e
e8f5400
982359b
cdf5ec6
690e718
16efeb6
ef8602c
f4032cb
2336276
2c7c748
794f605
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there an existing
collect
function that you are modelling this logic off-of? I'm just curious how other libraries are using thisThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really, I was trying pratica as part of another project and wrote this when verifying and translating an array to allow for code that looked like
inputs.map(translate).collect()
.I thought it might be a nice inclusion here, but I can't say I've done any research into wider implementations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've done some digging, turns out I did something similar in Rust ages ago, which explains why I thought to call it collect. Only difference is Rust returns Err with the first found error, so
Vec<Result<T, E>> -> Result<Vec<T>, E>
, rather thanVec<Result<T, E>> -> Result<Vec<T>, Vec<E>>