Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use clone_from from hashbrown::{HashMap,HashSet}. #80400

Merged
merged 1 commit into from
Dec 27, 2020
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
19 changes: 18 additions & 1 deletion library/std/src/collections/hash/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,6 @@ use crate::sys;
/// // use the values stored in map
/// ```

#[derive(Clone)]
#[cfg_attr(not(test), rustc_diagnostic_item = "hashmap_type")]
#[stable(feature = "rust1", since = "1.0.0")]
pub struct HashMap<K, V, S = RandomState> {
Expand Down Expand Up @@ -1029,6 +1028,24 @@ where
}
}

#[stable(feature = "rust1", since = "1.0.0")]
impl<K, V, S> Clone for HashMap<K, V, S>
where
K: Clone,
V: Clone,
S: Clone,
{
#[inline]
fn clone(&self) -> Self {
Self { base: self.base.clone() }
}

#[inline]
fn clone_from(&mut self, other: &Self) {
self.base.clone_from(&other.base);
}
}

#[stable(feature = "rust1", since = "1.0.0")]
impl<K, V, S> PartialEq for HashMap<K, V, S>
where
Expand Down
18 changes: 17 additions & 1 deletion library/std/src/collections/hash/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ use super::map::{map_try_reserve_error, RandomState};
/// [`HashMap`]: crate::collections::HashMap
/// [`RefCell`]: crate::cell::RefCell
/// [`Cell`]: crate::cell::Cell
#[derive(Clone)]
#[cfg_attr(not(test), rustc_diagnostic_item = "hashset_type")]
#[stable(feature = "rust1", since = "1.0.0")]
pub struct HashSet<T, S = RandomState> {
Expand Down Expand Up @@ -932,6 +931,23 @@ where
}
}

#[stable(feature = "rust1", since = "1.0.0")]
impl<T, S> Clone for HashSet<T, S>
where
T: Clone,
S: Clone,
{
#[inline]
fn clone(&self) -> Self {
Self { base: self.base.clone() }
}

#[inline]
fn clone_from(&mut self, other: &Self) {
self.base.clone_from(&other.base);
}
}

#[stable(feature = "rust1", since = "1.0.0")]
impl<T, S> PartialEq for HashSet<T, S>
where
Expand Down