-
Notifications
You must be signed in to change notification settings - Fork 142
Closed
Labels
compatibility-breakingChanges that are (likely to be) breakingChanges that are (likely to be) breaking
Description
Please correct me if I'm wrong, but by taking ownership of the buffer, it seems to release the buffer as soon as the function exits, and subsequent code cannot use the buffer.
The method is defined as follows:
/// Writes a copy of `self` to the prefix of `bytes`.
///
/// `write_to_prefix` writes `self` to the first `size_of_val(self)` bytes
/// of `bytes`. If `bytes.len() < size_of_val(self)`, it returns `None`.
fn write_to_prefix<B: ByteSliceMut>(&self, mut bytes: B) -> Option<()> {
let size = mem::size_of_val(self);
if bytes.len() < size {
return None;
}
bytes[..size].copy_from_slice(self.as_bytes());
Some(())
}I think the method should only borrow the buffer.
Again, correct me if I'm wrong please!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
compatibility-breakingChanges that are (likely to be) breakingChanges that are (likely to be) breaking