support generic output#10
Merged
kornelski merged 3 commits intospace-wizards:masterfrom Jun 4, 2025
Merged
Conversation
kornelski
reviewed
Jun 3, 2025
|
|
||
| /// Apply a patch to an "old" file, returning the "new" file. | ||
| /// | ||
| /// `old` is the old file, `patch` will be read from with the patch,`new` is the buffer that will be written into. |
Collaborator
There was a problem hiding this comment.
Thanks for the PR!
Please add documentation and perhaps an example that it works with a &mut Vec, because the trait bounds don't make that obvious.
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.
📦 PR: Generalize
patchoutput buffer to supportAlignedVecand other custom writers✨ Summary
This PR generalizes the
patchfunction’s output buffer parameter (new) from a fixed&mut Vec<u8>to any type that implements:std::io::Write— for writing patch data,DerefMut<Target = [u8]>— for in-place mutation of the diff section.This allows the function to be used with buffer types like
AlignedVec, which provide memory alignment guarantees required for later reinterpretation (e.g., casting to typed data).🧪 What Changed
Developers may now need to explicitly specify the type:
✅ Benefits
Let me know if you want a version with a fallback function to keep compatibility for existing callers.