Skip to content

Commit a1e006a

Browse files
committed
Merge pull request 684 from tinou98/read-mut
2 parents fdc177d + 4003c50 commit a1e006a

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed

src/read.rs

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,71 @@ pub trait Read<'de>: private::Sealed {
111111
fn set_failed(&mut self, failed: &mut bool);
112112
}
113113

114+
impl<'de, R: Read<'de>> private::Sealed for &mut R {}
115+
impl<'de, R: Read<'de>> Read<'de> for &mut R {
116+
fn next(&mut self) -> Result<Option<u8>> {
117+
R::next(self)
118+
}
119+
120+
fn peek(&mut self) -> Result<Option<u8>> {
121+
R::peek(self)
122+
}
123+
124+
fn discard(&mut self) {
125+
R::discard(self)
126+
}
127+
128+
fn position(&self) -> Position {
129+
R::position(self)
130+
}
131+
132+
fn peek_position(&self) -> Position {
133+
R::peek_position(self)
134+
}
135+
136+
fn byte_offset(&self) -> usize {
137+
R::byte_offset(self)
138+
}
139+
140+
fn parse_str<'s>(&'s mut self, scratch: &'s mut Vec<u8>) -> Result<Reference<'de, 's, str>> {
141+
R::parse_str(self, scratch)
142+
}
143+
144+
fn parse_str_raw<'s>(
145+
&'s mut self,
146+
scratch: &'s mut Vec<u8>,
147+
) -> Result<Reference<'de, 's, [u8]>> {
148+
R::parse_str_raw(self, scratch)
149+
}
150+
151+
fn ignore_str(&mut self) -> Result<()> {
152+
R::ignore_str(self)
153+
}
154+
155+
fn decode_hex_escape(&mut self) -> Result<u16> {
156+
R::decode_hex_escape(self)
157+
}
158+
159+
#[cfg(feature = "raw_value")]
160+
fn begin_raw_buffering(&mut self) {
161+
R::begin_raw_buffering(self)
162+
}
163+
164+
#[cfg(feature = "raw_value")]
165+
fn end_raw_buffering<V>(&mut self, visitor: V) -> Result<V::Value>
166+
where
167+
V: Visitor<'de>,
168+
{
169+
R::end_raw_buffering(self, visitor)
170+
}
171+
172+
const should_early_return_if_failed: bool = R::should_early_return_if_failed;
173+
174+
fn set_failed(&mut self, failed: &mut bool) {
175+
R::set_failed(self, failed)
176+
}
177+
}
178+
114179
pub struct Position {
115180
pub line: usize,
116181
pub column: usize,

0 commit comments

Comments
 (0)