Don't require a Box wrapper on Bindings::write() - #3317
Merged
Merged
Conversation
The function in question doesn't store the `dyn Write` trait object anywhere, allowing us to pass a plain `&mut dyn Write` (which is also implemented for `&mut Box<dyn Write>` allowing the existing CLI parser to operate normally). This in turn no longer requires users of `bindgen` to wrap their `&mut File` or `&mut Vec<u8>` in a moved `Box` just to be able to give temporary mutable access to the `write() function`.
MarijnS95
force-pushed
the
write-no-box
branch
from
November 11, 2025 11:36
b6f4f24 to
6decf66
Compare
Contributor
Author
|
Note that I am using this on a project where If there was an option for |
emilio
approved these changes
Dec 8, 2025
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.
The function in question doesn't store the
dyn Writetrait object anywhere, allowing us to pass a plain&mut dyn Write(which is also implemented for&mut Box<dyn Write>allowing the existing CLI parser to operate normally).This in turn no longer requires users of
bindgento wrap their&mut Fileor&mut Vec<u8>in a movedBoxjust to be able to give temporary mutable access to thewrite() function.