mirror of
https://github.com/openharmony/third_party_rust_indexmap.git
synced 2026-07-19 16:43:59 -04:00
+10
-7
@@ -166,10 +166,7 @@ impl<K, V, S> IndexMap<K, V, S> {
|
||||
#[inline]
|
||||
pub fn with_capacity_and_hasher(n: usize, hash_builder: S) -> Self {
|
||||
if n == 0 {
|
||||
IndexMap {
|
||||
core: IndexMapCore::new(),
|
||||
hash_builder,
|
||||
}
|
||||
Self::with_hasher(hash_builder)
|
||||
} else {
|
||||
IndexMap {
|
||||
core: IndexMapCore::with_capacity(n),
|
||||
@@ -178,9 +175,15 @@ impl<K, V, S> IndexMap<K, V, S> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Create a new map with `hash_builder`
|
||||
pub fn with_hasher(hash_builder: S) -> Self {
|
||||
Self::with_capacity_and_hasher(0, hash_builder)
|
||||
/// Create a new map with `hash_builder`.
|
||||
///
|
||||
/// This function is `const`, so it
|
||||
/// can be called in `static` contexts.
|
||||
pub const fn with_hasher(hash_builder: S) -> Self {
|
||||
IndexMap {
|
||||
core: IndexMapCore::new(),
|
||||
hash_builder,
|
||||
}
|
||||
}
|
||||
|
||||
/// Computes in **O(1)** time.
|
||||
|
||||
+1
-1
@@ -120,7 +120,7 @@ impl<K, V> Entries for IndexMapCore<K, V> {
|
||||
|
||||
impl<K, V> IndexMapCore<K, V> {
|
||||
#[inline]
|
||||
pub(crate) fn new() -> Self {
|
||||
pub(crate) const fn new() -> Self {
|
||||
IndexMapCore {
|
||||
indices: RawTable::new(),
|
||||
entries: Vec::new(),
|
||||
|
||||
+5
-2
@@ -155,8 +155,11 @@ impl<T, S> IndexSet<T, S> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Create a new set with `hash_builder`
|
||||
pub fn with_hasher(hash_builder: S) -> Self {
|
||||
/// Create a new set with `hash_builder`.
|
||||
///
|
||||
/// This function is `const`, so it
|
||||
/// can be called in `static` contexts.
|
||||
pub const fn with_hasher(hash_builder: S) -> Self {
|
||||
IndexSet {
|
||||
map: IndexMap::with_hasher(hash_builder),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user