-
Notifications
You must be signed in to change notification settings - Fork 139
Open
Description
The write_to_prefix function is generating a panic path in our code, and I am pretty sure it is the bytes[..size].copy_from_slice(self.as_bytes()); line. The compiler doesn't have enough information to elide the slice comparison check.
If the code was written like the following, the compiler should not generate a panic path
fn write_to_prefix<B: ByteSliceMut>(&self, mut bytes: B) -> Option<()> {
let source = self.as_bytes();
if bytes.len() < source.len() {
return None;
}
bytes[..size].copy_from_slice(source);
Some(())
}Metadata
Metadata
Assignees
Labels
No labels