Skip to content

Commit

Permalink
Merge pull request #2240 from Kixunil/patch-1
Browse files Browse the repository at this point in the history
Call `reserve()` in `DeserializeSeed` example
  • Loading branch information
dtolnay committed Jun 30, 2022
2 parents 845b900 + 41ffa6d commit 6c098e4
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions serde/src/de/mod.rs
Expand Up @@ -708,6 +708,11 @@ impl<T> DeserializeOwned for T where T: for<'de> Deserialize<'de> {}
/// where
/// A: SeqAccess<'de>,
/// {
/// // Decrease the number of reallocations if there are many elements
/// if let Some(size_hint) = seq.size_hint() {
/// self.0.reserve(size_hint);
/// }
///
/// // Visit each element in the inner array and push it onto
/// // the existing vector.
/// while let Some(elem) = seq.next_element()? {
Expand Down

0 comments on commit 6c098e4

Please sign in to comment.