Rename Decoder::read_nil and read_unit.

Because `()` is called "unit" and it makes it match
`Encoder::emit_unit`.
This commit is contained in:
Nicholas Nethercote 2022-01-19 12:09:19 +11:00
parent cbaeec14f9
commit 88600a6d7f
5 changed files with 7 additions and 7 deletions

View file

@ -2419,7 +2419,7 @@ impl<S: Encoder> rustc_serialize::Encodable<S> for AttrId {
impl<D: Decoder> rustc_serialize::Decodable<D> for AttrId { impl<D: Decoder> rustc_serialize::Decodable<D> for AttrId {
fn decode(d: &mut D) -> Result<AttrId, D::Error> { fn decode(d: &mut D) -> Result<AttrId, D::Error> {
d.read_nil().map(|_| crate::attr::mk_attr_id()) d.read_unit().map(|_| crate::attr::mk_attr_id())
} }
} }

View file

@ -459,7 +459,7 @@ macro_rules! implement_ty_decoder {
type Error = String; type Error = String;
$crate::__impl_decoder_methods! { $crate::__impl_decoder_methods! {
read_nil -> (); read_unit -> ();
read_u128 -> u128; read_u128 -> u128;
read_u64 -> u64; read_u64 -> u64;

View file

@ -2240,7 +2240,7 @@ macro_rules! read_primitive {
impl crate::Decoder for Decoder { impl crate::Decoder for Decoder {
type Error = DecoderError; type Error = DecoderError;
fn read_nil(&mut self) -> DecodeResult<()> { fn read_unit(&mut self) -> DecodeResult<()> {
expect!(self.pop(), Null) expect!(self.pop(), Null)
} }

View file

@ -567,7 +567,7 @@ impl<'a> serialize::Decoder for Decoder<'a> {
type Error = String; type Error = String;
#[inline] #[inline]
fn read_nil(&mut self) -> Result<(), Self::Error> { fn read_unit(&mut self) -> Result<(), Self::Error> {
Ok(()) Ok(())
} }

View file

@ -177,7 +177,7 @@ pub trait Decoder {
type Error; type Error;
// Primitive types: // Primitive types:
fn read_nil(&mut self) -> Result<(), Self::Error>; fn read_unit(&mut self) -> Result<(), Self::Error>;
fn read_usize(&mut self) -> Result<usize, Self::Error>; fn read_usize(&mut self) -> Result<usize, Self::Error>;
fn read_u128(&mut self) -> Result<u128, Self::Error>; fn read_u128(&mut self) -> Result<u128, Self::Error>;
fn read_u64(&mut self) -> Result<u64, Self::Error>; fn read_u64(&mut self) -> Result<u64, Self::Error>;
@ -436,7 +436,7 @@ impl<S: Encoder> Encodable<S> for () {
impl<D: Decoder> Decodable<D> for () { impl<D: Decoder> Decodable<D> for () {
fn decode(d: &mut D) -> Result<(), D::Error> { fn decode(d: &mut D) -> Result<(), D::Error> {
d.read_nil() d.read_unit()
} }
} }
@ -448,7 +448,7 @@ impl<S: Encoder, T> Encodable<S> for PhantomData<T> {
impl<D: Decoder, T> Decodable<D> for PhantomData<T> { impl<D: Decoder, T> Decodable<D> for PhantomData<T> {
fn decode(d: &mut D) -> Result<PhantomData<T>, D::Error> { fn decode(d: &mut D) -> Result<PhantomData<T>, D::Error> {
d.read_nil()?; d.read_unit()?;
Ok(PhantomData) Ok(PhantomData)
} }
} }