-
Notifications
You must be signed in to change notification settings - Fork 37
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
Make [Try]IntoCtx borrow instead of copying #47
Closed
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
749f752
Borrow instead of copying in IntoCtx, TryIntoCtx, Cwrite, Pwrite
willglynn ad6df6e
Add a test which complains about unaligned field accesses
willglynn 2a73c26
Serialize #[repr(packed)] structs by copying out their fields
willglynn efc16f3
Change iowrite() to also take a reference
willglynn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.
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.
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.
This and the 3 others are a huge PR, will take me a bit to review, appreciate your patience, @willglynn.
I would like to note that having to take the reference now of variables, literals, makes me pretty sad...
I feel like it jars slightly with the original and basic purpose of scroll, which was to "serialize" numbers and PODs.
I do wish there had been a little more discussion before this enormous (and amazing PR!), specifically, whether we can have our cake and eat it too w.r.t. TryInto for the primitives.
Specifically, I'm wondering if there's a compromise, so that we can still pass either references or owned values to the pwrite/iowrite.
Maybe it's just me but i do find it a usability paper cut and find it less attractive that I have to take references to pwrite now, but perhaps I'm used to the old way.
So, is there some generic magic we can use to do this? Guessing wildy and randomly:
On the other hand, in my case where the struct was too large to be put on the stack, and I had to box it, even if we did say 2., this would still probably eventually blow the stack? Or perhaps not. Have to think about it, and its late and a Thursday :)
Similarly, and against my original sadness, if I'm able to pwrite out a huge boxed struct that auto-derives pwrite, that would actually make me happy and would counteract any bitterness of no longer being able to pwrite raw deadbeefs :D
Dunno, just some thoughts, feel free to respond whenever you get the time (and that goes for anyone else who's watch).
Regardless, thanks for your amazing work here @willglynn and the robustness and tenacity of the changes, great work!
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.
Cheers! And yeah, this is why I went and did these PRs even with limited discussion: I didn't know how this concept would look until it was done 😄
I'll ponder the generics question. There might be a way we can make
pwrite()
be&
-agnostic while keepingTryIntoCtx
take&self
– that'd let youpwrite()
either by value or by reference without consumingself
during the write.