1
Fork 0

Rollup merge of #93456 - bjorn3:remove_unnecessary_unsafe, r=michaelwoerister

Remove an unnecessary transmute from opaque::Encoder
This commit is contained in:
Eric Huss 2022-01-31 20:12:57 -08:00 committed by GitHub
commit 3aa2e4584b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -130,8 +130,7 @@ impl serialize::Encoder for Encoder {
#[inline]
fn emit_i8(&mut self, v: i8) -> EncodeResult {
let as_u8: u8 = unsafe { std::mem::transmute(v) };
self.emit_u8(as_u8)
self.emit_u8(v as u8)
}
#[inline]
@ -629,9 +628,9 @@ impl<'a> serialize::Decoder for Decoder<'a> {
#[inline]
fn read_i8(&mut self) -> i8 {
let as_u8 = self.data[self.position];
let value = self.data[self.position];
self.position += 1;
unsafe { ::std::mem::transmute(as_u8) }
value as i8
}
#[inline]