Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 4 additions & 13 deletions library/alloc/src/collections/btree/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -501,11 +501,8 @@ impl<K, V> BTreeMap<K, V> {
/// assert!(a.is_empty());
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
pub fn clear(&mut self)
where
K: Ord,
{
*self = BTreeMap::new();
pub fn clear(&mut self) {
*self = BTreeMap { root: None, length: 0 };
}

/// Returns a reference to the value corresponding to the key.
Expand Down Expand Up @@ -1226,10 +1223,7 @@ impl<K, V> BTreeMap<K, V> {
/// ```
#[inline]
#[unstable(feature = "map_into_keys_values", issue = "75294")]
pub fn into_keys(self) -> IntoKeys<K, V>
where
K: Ord,
{
pub fn into_keys(self) -> IntoKeys<K, V> {
IntoKeys { inner: self.into_iter() }
}

Expand All @@ -1252,10 +1246,7 @@ impl<K, V> BTreeMap<K, V> {
/// ```
#[inline]
#[unstable(feature = "map_into_keys_values", issue = "75294")]
pub fn into_values(self) -> IntoValues<K, V>
where
K: Ord,
{
pub fn into_values(self) -> IntoValues<K, V> {
IntoValues { inner: self.into_iter() }
}
}
Expand Down
17 changes: 15 additions & 2 deletions library/alloc/src/collections/btree/map/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1711,12 +1711,19 @@ fn test_ord_absence() {
fn map<K>(mut map: BTreeMap<K, ()>) {
map.is_empty();
map.len();
map.clear();
map.iter();
map.iter_mut();
map.keys();
map.values();
map.values_mut();
map.into_iter();
if true {
map.into_values();
} else if true {
map.into_iter();
} else {
map.into_keys();
}
}

fn map_debug<K: Debug>(mut map: BTreeMap<K, ()>) {
Expand All @@ -1726,7 +1733,13 @@ fn test_ord_absence() {
format!("{:?}", map.keys());
format!("{:?}", map.values());
format!("{:?}", map.values_mut());
format!("{:?}", map.into_iter());
if true {
format!("{:?}", map.into_iter());
} else if true {
format!("{:?}", map.into_keys());
} else {
format!("{:?}", map.into_values());
}
}

fn map_clone<K: Clone>(mut map: BTreeMap<K, ()>) {
Expand Down
5 changes: 1 addition & 4 deletions library/alloc/src/collections/btree/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -457,10 +457,7 @@ impl<T> BTreeSet<T> {
/// assert!(v.is_empty());
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
pub fn clear(&mut self)
where
T: Ord,
{
pub fn clear(&mut self) {
self.map.clear()
}

Expand Down
3 changes: 2 additions & 1 deletion library/alloc/src/collections/btree/set/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -641,9 +641,10 @@ fn test_send() {

#[allow(dead_code)]
fn test_ord_absence() {
fn set<K>(set: BTreeSet<K>) {
fn set<K>(mut set: BTreeSet<K>) {
set.is_empty();
set.len();
set.clear();
set.iter();
set.into_iter();
}
Expand Down