Implement Versionize for VecDeque#13
Open
alexandruag wants to merge 1 commit intofirecracker-microvm:mainfrom
Open
Implement Versionize for VecDeque#13alexandruag wants to merge 1 commit intofirecracker-microvm:mainfrom
alexandruag wants to merge 1 commit intofirecracker-microvm:mainfrom
Conversation
Signed-off-by: Alexandru Agache <aagch@amazon.com>
acatangiu
reviewed
Jun 4, 2020
Contributor
acatangiu
left a comment
There was a problem hiding this comment.
LGTM, just one small suggestion.
| app_version: u16, | ||
| ) -> VersionizeResult<Self> { | ||
| let mut v = VecDeque::new(); | ||
| let len: u64 = bincode::deserialize_from(&mut reader) |
Contributor
There was a problem hiding this comment.
nit-ish:
Serialized len() is usize: https://doc.rust-lang.org/std/collections/struct.VecDeque.html#method.len
Let's use the same thing here just in case u64 differs in size from usize:
Suggested change
| let len: u64 = bincode::deserialize_from(&mut reader) | |
| let len: usize = bincode::deserialize_from(&mut reader) |
sandreim
reviewed
Jun 4, 2020
| ) -> VersionizeResult<()> { | ||
| // Serialize in the same fashion as bincode: | ||
| // Write len. | ||
| bincode::serialize_into(&mut writer, &self.len()) |
Contributor
There was a problem hiding this comment.
Can we rely on the Vec primitive here and just use Into/From instead of duplicating the Vec code:
Docs say: This avoids reallocating where possible, but the conditions for that are strict, and subject to change, and so shouldn't be relied upon unless the Vec came from From<VecDeque> and hasn't been reallocated.
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.
Reason for This PR
Added an implementation of
VersionizeforVecDequetoprimitives.rs.License Acceptance
By submitting this pull request, I confirm that my contribution is made under
the terms of the Apache 2.0 license.
PR Checklist
git commit -s).unsafecode is properly documented.CHANGELOG.md.