Skip to content

Commit

Permalink
Inline SerializeSeq::serialize_element into serialize_bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Jul 11, 2023
1 parent 55a7f5c commit 1b72f2b
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/ser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ where
.formatter
.begin_array(&mut self.writer)
.map_err(Error::io));
let mut seq = if value.is_empty() {
let seq = if value.is_empty() {
tri!(self
.formatter
.end_array(&mut self.writer)
Expand All @@ -203,14 +203,21 @@ where
state: State::Empty,
}
} else {
Compound::Map {
ser: self,
state: State::First,
let mut state = State::First;
for byte in value {
tri!(self
.formatter
.begin_array_value(&mut self.writer, state == State::First)
.map_err(Error::io));
state = State::Rest;
tri!(byte.serialize(&mut *self));
tri!(self
.formatter
.end_array_value(&mut self.writer)
.map_err(Error::io));
}
Compound::Map { ser: self, state }
};
for byte in value {
tri!(seq.serialize_element(byte));
}
seq.end()
}

Expand Down

0 comments on commit 1b72f2b

Please sign in to comment.