mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-06-12 15:31:07 +00:00
Simplify down some code
This commit is contained in:
@@ -204,11 +204,7 @@ pub trait Deserializer<E>: Iterator<Result<Token, E>> {
|
|||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn expect_token(&mut self) -> Result<Token, E> {
|
fn expect_token(&mut self) -> Result<Token, E> {
|
||||||
match self.next() {
|
self.next().unwrap_or_else(|| Err(self.end_of_stream_error()))
|
||||||
Some(Ok(token)) => Ok(token),
|
|
||||||
Some(Err(err)) => Err(err),
|
|
||||||
None => Err(self.end_of_stream_error()),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
@@ -1216,10 +1212,7 @@ mod tests {
|
|||||||
impl<Iter: Iterator<Token>> Iterator<Result<Token, Error>> for TokenDeserializer<Iter> {
|
impl<Iter: Iterator<Token>> Iterator<Result<Token, Error>> for TokenDeserializer<Iter> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn next(&mut self) -> option::Option<Result<Token, Error>> {
|
fn next(&mut self) -> option::Option<Result<Token, Error>> {
|
||||||
match self.tokens.next() {
|
self.tokens.next().map(|token| Ok(token))
|
||||||
None => None,
|
|
||||||
Some(token) => Some(Ok(token)),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user