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.
Just shortening a match statement!
Commit message below:
The previous big match statement did three separate things in the
same deeply indented code block:
Preparing the buffer was simplified by just calling
ensure_trailing_newline
beforehand, as that's essentially whatthe special cases deep inside the match statement were doing
anyway. This is done indiscriminately due to the borrow checker,
which wouldn't like us manipulating the buffer to add a newline
while we held an immutable reference to it in
buffer
. This hasthe unfortunate-ish side effect of requiring modifications to the
tests to account for the fact that a trailing newline is added.
Separating 2 and 3 allows us to refocus the match statement on
identification, and, if there is content, we can paste later down
the function.
1 and 2 are still homogeneous in the match statement, which isn't
super pretty, but, as they both depend on the same data (and
conditionals thereof), it's not too big a deal.