-
Notifications
You must be signed in to change notification settings - Fork 59
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
Add convenience impls for common types #137
Conversation
4d0bf30
to
e7a75be
Compare
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.
One question on the logic, otherwise LGTM
let elem = elem.to_bytes_le()?; | ||
bytes.extend_from_slice(&elem); | ||
// Make sure that there's enough capacity to avoid reallocations. | ||
bytes.reserve(elem.len() * (self.len() - 1)); |
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.
Do we do this at each iteration of the loop in case the elements have different len
?
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 actually wasn't the smartest logic, but it kind of works out: if the elem.len()
is less than or equal to that for previous elem
s, then don't change the capacity, resulting in a no-op. If elem.len()
is larger than that for previous elem
s, it will reserve more space.
Description
closes: #XXXX
Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.
Pending
section inCHANGELOG.md
Files changed
in the Github PR explorer