From dce1f309de6732efed7c724cbc953632c41bab66 Mon Sep 17 00:00:00 2001 From: TennyZhuang Date: Mon, 22 Aug 2022 14:28:11 +0800 Subject: [PATCH 1/4] make with_hasher_in const (consistent with with_hasher) Signed-off-by: TennyZhuang --- src/map.rs | 5 +++-- src/raw/mod.rs | 2 +- src/set.rs | 8 +++++--- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/map.rs b/src/map.rs index 5e039e2392..1cac589510 100644 --- a/src/map.rs +++ b/src/map.rs @@ -429,7 +429,8 @@ impl HashMap { /// Creates an empty `HashMap` which will use the given hash builder to hash /// keys. It will be allocated with the given allocator. /// - /// The created map has the default initial capacity. + /// The hash map is initially created with a capacity of 0, so it will not + /// allocate until it is first inserted into. /// /// Warning: `hash_builder` is normally randomly generated, and /// is designed to allow HashMaps to be resistant to attacks that @@ -447,7 +448,7 @@ impl HashMap { /// map.insert(1, 2); /// ``` #[cfg_attr(feature = "inline-more", inline)] - pub fn with_hasher_in(hash_builder: S, alloc: A) -> Self { + pub const fn with_hasher_in(hash_builder: S, alloc: A) -> Self { Self { hash_builder, table: RawTable::new_in(alloc), diff --git a/src/raw/mod.rs b/src/raw/mod.rs index daba4f8c85..48ece40130 100644 --- a/src/raw/mod.rs +++ b/src/raw/mod.rs @@ -426,7 +426,7 @@ impl RawTable { /// leave the data pointer dangling since that bucket is never written to /// due to our load factor forcing us to always have at least 1 free bucket. #[inline] - pub fn new_in(alloc: A) -> Self { + pub const fn new_in(alloc: A) -> Self { Self { table: RawTableInner::new_in(alloc), marker: PhantomData, diff --git a/src/set.rs b/src/set.rs index f91cb54fcb..6359ecc23a 100644 --- a/src/set.rs +++ b/src/set.rs @@ -387,7 +387,8 @@ impl HashSet { /// Creates a new empty hash set which will use the given hasher to hash /// keys. /// - /// The hash set is also created with the default initial capacity. + /// The hash set is initially created with a capacity of 0, so it will not + /// allocate until it is first inserted into. /// /// Warning: `hasher` is normally randomly generated, and /// is designed to allow `HashSet`s to be resistant to attacks that @@ -464,7 +465,8 @@ where /// Creates a new empty hash set which will use the given hasher to hash /// keys. /// - /// The hash set is also created with the default initial capacity. + /// The hash set is initially created with a capacity of 0, so it will not + /// allocate until it is first inserted into. /// /// Warning: `hasher` is normally randomly generated, and /// is designed to allow `HashSet`s to be resistant to attacks that @@ -482,7 +484,7 @@ where /// set.insert(2); /// ``` #[cfg_attr(feature = "inline-more", inline)] - pub fn with_hasher_in(hasher: S, alloc: A) -> Self { + pub const fn with_hasher_in(hasher: S, alloc: A) -> Self { Self { map: HashMap::with_hasher_in(hasher, alloc), } From 1c58b1ea12668d9ffc0e2cae84c3db86dedd60a8 Mon Sep 17 00:00:00 2001 From: TennyZhuang Date: Mon, 22 Aug 2022 14:43:23 +0800 Subject: [PATCH 2/4] add a feature Signed-off-by: TennyZhuang --- src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lib.rs b/src/lib.rs index e43165dd63..f7e52d0d16 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -14,6 +14,7 @@ feature = "nightly", feature( test, + const_fn_trait_bound, core_intrinsics, dropck_eyepatch, min_specialization, From 630f3a720427606616d1633a6718dc31b2347545 Mon Sep 17 00:00:00 2001 From: TennyZhuang Date: Sun, 2 Oct 2022 09:40:22 +0800 Subject: [PATCH 3/4] ci: bump the toolchain version Signed-off-by: TennyZhuang --- .github/workflows/rust.yml | 8 ++++---- README.md | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 1739efc95b..e6a4f21e17 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -50,7 +50,7 @@ jobs: thumbv6m-none-eabi, x86_64-pc-windows-gnu, ] - channel: [1.58.1, nightly] + channel: [1.61.0, nightly] include: - os: macos-latest target: x86_64-apple-darwin @@ -60,13 +60,13 @@ jobs: channel: nightly - os: macos-latest target: x86_64-apple-darwin - channel: 1.58.1 + channel: 1.61.0 - os: windows-latest target: x86_64-pc-windows-msvc - channel: 1.58.1 + channel: 1.61.0 - os: ubuntu-latest target: x86_64-unknown-linux-gnu - channel: 1.56.1 + channel: 1.61.0 - os: ubuntu-latest target: x86_64-unknown-linux-gnu channel: beta diff --git a/README.md b/README.md index 461cf494ca..f5fff54cb1 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ hashbrown [![Build Status](https://github.com/rust-lang/hashbrown/actions/workflows/rust.yml/badge.svg)](https://github.com/rust-lang/hashbrown/actions) [![Crates.io](https://img.shields.io/crates/v/hashbrown.svg)](https://crates.io/crates/hashbrown) [![Documentation](https://docs.rs/hashbrown/badge.svg)](https://docs.rs/hashbrown) -[![Rust](https://img.shields.io/badge/rust-1.56.1%2B-blue.svg?maxAge=3600)](https://github.com/rust-lang/hashbrown) +[![Rust](https://img.shields.io/badge/rust-1.61.0%2B-blue.svg?maxAge=3600)](https://github.com/rust-lang/hashbrown) This crate is a Rust port of Google's high-performance [SwissTable] hash map, adapted to make it a drop-in replacement for Rust's standard `HashMap` From 92618d7640bff3f13fd35e139d24d1aa17bdd9fd Mon Sep 17 00:00:00 2001 From: TennyZhuang Date: Mon, 3 Oct 2022 00:21:14 +0800 Subject: [PATCH 4/4] remove the feature Signed-off-by: TennyZhuang --- src/lib.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index f7e52d0d16..e43165dd63 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -14,7 +14,6 @@ feature = "nightly", feature( test, - const_fn_trait_bound, core_intrinsics, dropck_eyepatch, min_specialization,