BTree(Set|Map): Guarantee that IntoIter will iterate in sorted by key order

This commit is contained in:
ultrabear 2024-03-21 00:54:50 -07:00
parent 6e1f7b538a
commit f6f89dc202
No known key found for this signature in database
GPG Key ID: 6A5BDAF57DFFD6A0
2 changed files with 4 additions and 2 deletions

View File

@ -415,7 +415,7 @@ fn default() -> Self {
}
}
/// An owning iterator over the entries of a `BTreeMap`.
/// An owning iterator over the entries of a `BTreeMap`, sorted by key.
///
/// This `struct` is created by the [`into_iter`] method on [`BTreeMap`]
/// (provided by the [`IntoIterator`] trait). See its documentation for more.
@ -1632,6 +1632,7 @@ pub(super) fn iter(&self) -> Iter<'_, K, V> {
}
}
/// Gets an owning iterator over the entries of the map, sorted by key.
#[stable(feature = "rust1", since = "1.0.0")]
impl<K, V, A: Allocator + Clone> IntoIterator for BTreeMap<K, V, A> {
type Item = (K, V);

View File

@ -140,7 +140,7 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
}
}
/// An owning iterator over the items of a `BTreeSet`.
/// An owning iterator over the items of a `BTreeSet` in ascending order.
///
/// This `struct` is created by the [`into_iter`] method on [`BTreeSet`]
/// (provided by the [`IntoIterator`] trait). See its documentation for more.
@ -1232,6 +1232,7 @@ fn from_sorted_iter<I: Iterator<Item = T>>(iter: I, alloc: A) -> BTreeSet<T, A>
}
}
/// Gets an owning iterator over the elements of the `BTreeSet` in ascending order.
#[stable(feature = "rust1", since = "1.0.0")]
impl<T, A: Allocator + Clone> IntoIterator for BTreeSet<T, A> {
type Item = T;