Call reserve() in DeserializeSeed example

This suggests calling `reserve()` in example code so that people who ~blindly copy it get faster code.
This commit is contained in:
Martin Habovštiak 2022-06-30 18:28:52 +02:00 committed by GitHub
parent 845b900fd5
commit 41ffa6df7e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -708,6 +708,11 @@ impl<T> DeserializeOwned for T where T: for<'de> Deserialize<'de> {}
/// where /// where
/// A: SeqAccess<'de>, /// 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 /// // Visit each element in the inner array and push it onto
/// // the existing vector. /// // the existing vector.
/// while let Some(elem) = seq.next_element()? { /// while let Some(elem) = seq.next_element()? {