mirror of
https://github.com/rust-lang/rust.git
synced 2024-10-31 22:41:50 +00:00
Reorder some MemDecoder
methods.
So they match the order in the `Decoder` trait.
This commit is contained in:
parent
b71ce293e8
commit
58002faca0
@ -506,19 +506,19 @@ macro_rules! implement_ty_decoder {
|
||||
|
||||
impl<$($typaram ),*> Decoder for $DecoderName<$($typaram),*> {
|
||||
$crate::__impl_decoder_methods! {
|
||||
read_usize -> usize;
|
||||
read_u128 -> u128;
|
||||
read_u64 -> u64;
|
||||
read_u32 -> u32;
|
||||
read_u16 -> u16;
|
||||
read_u8 -> u8;
|
||||
read_usize -> usize;
|
||||
|
||||
read_isize -> isize;
|
||||
read_i128 -> i128;
|
||||
read_i64 -> i64;
|
||||
read_i32 -> i32;
|
||||
read_i16 -> i16;
|
||||
read_i8 -> i8;
|
||||
read_isize -> isize;
|
||||
|
||||
read_bool -> bool;
|
||||
read_char -> char;
|
||||
@ -531,13 +531,13 @@ macro_rules! implement_ty_decoder {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn position(&self) -> usize {
|
||||
self.opaque.position()
|
||||
fn peek_byte(&self) -> u8 {
|
||||
self.opaque.peek_byte()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn peek_byte(&self) -> u8 {
|
||||
self.opaque.peek_byte()
|
||||
fn position(&self) -> usize {
|
||||
self.opaque.position()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -442,9 +442,8 @@ macro_rules! read_leb128 {
|
||||
|
||||
impl<'a> Decoder for MemDecoder<'a> {
|
||||
#[inline]
|
||||
fn position(&self) -> usize {
|
||||
// SAFETY: This type guarantees start <= current
|
||||
unsafe { self.current.sub_ptr(self.start) }
|
||||
fn read_usize(&mut self) -> usize {
|
||||
read_leb128!(self, read_usize_leb128)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
@ -481,8 +480,8 @@ impl<'a> Decoder for MemDecoder<'a> {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn read_usize(&mut self) -> usize {
|
||||
read_leb128!(self, read_usize_leb128)
|
||||
fn read_isize(&mut self) -> isize {
|
||||
read_leb128!(self, read_isize_leb128)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
@ -505,11 +504,6 @@ impl<'a> Decoder for MemDecoder<'a> {
|
||||
i16::from_le_bytes(self.read_array())
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn read_isize(&mut self) -> isize {
|
||||
read_leb128!(self, read_isize_leb128)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn read_raw_bytes(&mut self, bytes: usize) -> &'a [u8] {
|
||||
if bytes > self.remaining() {
|
||||
@ -532,6 +526,12 @@ impl<'a> Decoder for MemDecoder<'a> {
|
||||
// Since we just checked current == end, the current pointer must be inbounds.
|
||||
unsafe { *self.current }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn position(&self) -> usize {
|
||||
// SAFETY: This type guarantees start <= current
|
||||
unsafe { self.current.sub_ptr(self.start) }
|
||||
}
|
||||
}
|
||||
|
||||
// Specializations for contiguous byte sequences follow. The default implementations for slices
|
||||
|
@ -31,13 +31,13 @@ const STR_SENTINEL: u8 = 0xC1;
|
||||
/// really makes sense to store floating-point values at all.
|
||||
/// (If you need it, revert <https://github.com/rust-lang/rust/pull/109984>.)
|
||||
pub trait Encoder {
|
||||
// Primitive types:
|
||||
fn emit_usize(&mut self, v: usize);
|
||||
fn emit_u128(&mut self, v: u128);
|
||||
fn emit_u64(&mut self, v: u64);
|
||||
fn emit_u32(&mut self, v: u32);
|
||||
fn emit_u16(&mut self, v: u16);
|
||||
fn emit_u8(&mut self, v: u8);
|
||||
|
||||
fn emit_isize(&mut self, v: isize);
|
||||
fn emit_i128(&mut self, v: i128);
|
||||
fn emit_i64(&mut self, v: i64);
|
||||
@ -89,13 +89,13 @@ pub trait Encoder {
|
||||
/// really makes sense to store floating-point values at all.
|
||||
/// (If you need it, revert <https://github.com/rust-lang/rust/pull/109984>.)
|
||||
pub trait Decoder {
|
||||
// Primitive types:
|
||||
fn read_usize(&mut self) -> usize;
|
||||
fn read_u128(&mut self) -> u128;
|
||||
fn read_u64(&mut self) -> u64;
|
||||
fn read_u32(&mut self) -> u32;
|
||||
fn read_u16(&mut self) -> u16;
|
||||
fn read_u8(&mut self) -> u8;
|
||||
|
||||
fn read_isize(&mut self) -> isize;
|
||||
fn read_i128(&mut self) -> i128;
|
||||
fn read_i64(&mut self) -> i64;
|
||||
|
Loading…
Reference in New Issue
Block a user