Skip to content

Commit

Permalink
Move Read &mut impl after other Read impls
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Jul 26, 2020
1 parent a1e006a commit 7b86e66
Showing 1 changed file with 68 additions and 65 deletions.
133 changes: 68 additions & 65 deletions src/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,71 +111,6 @@ pub trait Read<'de>: private::Sealed {
fn set_failed(&mut self, failed: &mut bool);
}

impl<'de, R: Read<'de>> private::Sealed for &mut R {}
impl<'de, R: Read<'de>> Read<'de> for &mut R {
fn next(&mut self) -> Result<Option<u8>> {
R::next(self)
}

fn peek(&mut self) -> Result<Option<u8>> {
R::peek(self)
}

fn discard(&mut self) {
R::discard(self)
}

fn position(&self) -> Position {
R::position(self)
}

fn peek_position(&self) -> Position {
R::peek_position(self)
}

fn byte_offset(&self) -> usize {
R::byte_offset(self)
}

fn parse_str<'s>(&'s mut self, scratch: &'s mut Vec<u8>) -> Result<Reference<'de, 's, str>> {
R::parse_str(self, scratch)
}

fn parse_str_raw<'s>(
&'s mut self,
scratch: &'s mut Vec<u8>,
) -> Result<Reference<'de, 's, [u8]>> {
R::parse_str_raw(self, scratch)
}

fn ignore_str(&mut self) -> Result<()> {
R::ignore_str(self)
}

fn decode_hex_escape(&mut self) -> Result<u16> {
R::decode_hex_escape(self)
}

#[cfg(feature = "raw_value")]
fn begin_raw_buffering(&mut self) {
R::begin_raw_buffering(self)
}

#[cfg(feature = "raw_value")]
fn end_raw_buffering<V>(&mut self, visitor: V) -> Result<V::Value>
where
V: Visitor<'de>,
{
R::end_raw_buffering(self, visitor)
}

const should_early_return_if_failed: bool = R::should_early_return_if_failed;

fn set_failed(&mut self, failed: &mut bool) {
R::set_failed(self, failed)
}
}

pub struct Position {
pub line: usize,
pub column: usize,
Expand Down Expand Up @@ -760,6 +695,74 @@ impl<'a> Read<'a> for StrRead<'a> {

//////////////////////////////////////////////////////////////////////////////

impl<'de, R: Read<'de>> private::Sealed for &mut R {}

impl<'de, R: Read<'de>> Read<'de> for &mut R {
fn next(&mut self) -> Result<Option<u8>> {
R::next(self)
}

fn peek(&mut self) -> Result<Option<u8>> {
R::peek(self)
}

fn discard(&mut self) {
R::discard(self)
}

fn position(&self) -> Position {
R::position(self)
}

fn peek_position(&self) -> Position {
R::peek_position(self)
}

fn byte_offset(&self) -> usize {
R::byte_offset(self)
}

fn parse_str<'s>(&'s mut self, scratch: &'s mut Vec<u8>) -> Result<Reference<'de, 's, str>> {
R::parse_str(self, scratch)
}

fn parse_str_raw<'s>(
&'s mut self,
scratch: &'s mut Vec<u8>,
) -> Result<Reference<'de, 's, [u8]>> {
R::parse_str_raw(self, scratch)
}

fn ignore_str(&mut self) -> Result<()> {
R::ignore_str(self)
}

fn decode_hex_escape(&mut self) -> Result<u16> {
R::decode_hex_escape(self)
}

#[cfg(feature = "raw_value")]
fn begin_raw_buffering(&mut self) {
R::begin_raw_buffering(self)
}

#[cfg(feature = "raw_value")]
fn end_raw_buffering<V>(&mut self, visitor: V) -> Result<V::Value>
where
V: Visitor<'de>,
{
R::end_raw_buffering(self, visitor)
}

const should_early_return_if_failed: bool = R::should_early_return_if_failed;

fn set_failed(&mut self, failed: &mut bool) {
R::set_failed(self, failed)
}
}

//////////////////////////////////////////////////////////////////////////////

/// Marker for whether StreamDeserializer can implement FusedIterator.
pub trait Fused: private::Sealed {}
impl<'a> Fused for SliceRead<'a> {}
Expand Down

0 comments on commit 7b86e66

Please sign in to comment.