Repository navigation
Refactor maybe_item to use Marker argument - #987
Merged
Merged
Conversation
Contributor
|
✌️ pcpthm can now approve this pull request |
matklad
reviewed
Mar 17, 2019
matklad
left a comment
Contributor
There was a problem hiding this comment.
Sweet, this is significantly simpler now!
I've left a couple of stylistic comments, but otherwise r=me
bors delegate+
| m.complete(p, ERROR); | ||
| None | ||
| } else { | ||
| Some(m) |
Contributor
There was a problem hiding this comment.
Instead of lislint None in every branch, I think we can use return Some here, and then just a single None at the end of the function
| } | ||
| m = match maybe_item(p, m, flavor) { | ||
| Some(m) => m, | ||
| None => return, |
Contributor
There was a problem hiding this comment.
This gave me a pause: Option has an inverted modality here, where None means "success" and Some is an error. What do you think about making the return type be Result<(), Marker> instead?
| m.complete(p, kind); | ||
| } | ||
| items::MaybeItem::Modifiers => { | ||
| m = match items::maybe_item(p, m, items::ItemFlavor::Mod) { |
Contributor
There was a problem hiding this comment.
I tink we can write let m = here, to avoid making m mutable.
Contributor
Author
|
bors r+ |
bors Bot
added a commit
that referenced
this pull request
Mar 18, 2019
987: Refactor maybe_item to use Marker argument r=pcpthm a=pcpthm As suggested at <#980 (comment)>. For expression paring functions, changing signature - from `fn(&mut Parser) -> Option<CompletedMarker>` to `fn(&mut Parser, Marker) -> Result<CompletedMarker, Marker>` - from `fn(&mut Parser) -> CompletedMarker` to `fn(&mut Parser, Marker) -> CompletedMarker` is my plan. Co-authored-by: pcpthm <pcpthm@gmail.com>
Contributor
Build succeeded |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
As suggested at #980 (comment).
For expression paring functions, changing signature
fn(&mut Parser) -> Option<CompletedMarker>tofn(&mut Parser, Marker) -> Result<CompletedMarker, Marker>fn(&mut Parser) -> CompletedMarkertofn(&mut Parser, Marker) -> CompletedMarkeris my plan.