From f593f59c8a2d1de2d8972f14fb15fbf8df70699b Mon Sep 17 00:00:00 2001 From: arya dradjica Date: Fri, 19 Jun 2026 11:54:00 +0200 Subject: [PATCH] Use `hashbrown` over `std` hash tables `hashbrown` is no-std compatible! --- Cargo.lock | 16 ++++++++-------- Cargo.toml | 6 +++--- src/rdata/svcb/value.rs | 8 ++++---- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fea4c40f..3e4391ad 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -11,12 +11,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "allocator-api2" -version = "0.2.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" - [[package]] name = "anyhow" version = "1.0.102" @@ -286,6 +280,12 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" +[[package]] +name = "foldhash" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb" + [[package]] name = "foreign-types" version = "0.3.2" @@ -441,7 +441,7 @@ version = "0.15.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1" dependencies = [ - "foldhash", + "foldhash 0.1.5", ] [[package]] @@ -450,7 +450,7 @@ version = "0.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a" dependencies = [ - "allocator-api2", + "foldhash 0.2.0", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index a1101532..e7ce8bc4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -49,7 +49,7 @@ arc-swap = { version = "1.7.0", optional = true } bytes = { version = "1.2", optional = true, default-features = false } chrono = { version = "0.4.35", optional = true, default-features = false } # 0.4.35 deprecates Duration::seconds() futures-util = { version = "0.3", optional = true } -hashbrown = { version = "0.17.0", optional = true, default-features = false, features = ["allocator-api2", "inline-more"] } # 0.14.2 introduces explicit hashing +hashbrown = { version = "0.17.0", optional = true, default-features = false, features = ["default-hasher", "inline-more"] } heapless = { version = "0.9.2", optional = true } libc = { version = "0.2.153", default-features = false, optional = true } # 0.2.79 is the first version that has IP_PMTUDISC_OMIT log = { version = "0.4.22", optional = true } @@ -73,7 +73,7 @@ tracing-subscriber = { version = "0.3.18", optional = true, features = ["env-fil default = ["std", "rand"] # Support for libraries -alloc = ["jiff/alloc", "octseq/alloc", "serde?/alloc"] +alloc = ["dep:hashbrown", "jiff/alloc", "octseq/alloc", "serde?/alloc"] bumpalo = ["dep:bumpalo", "std"] bytes = ["dep:bytes", "octseq/bytes"] chrono = ["dep:chrono"] @@ -81,7 +81,7 @@ heapless = ["dep:heapless", "octseq/heapless"] rand = ["dep:rand"] serde = ["dep:serde", "octseq/serde"] smallvec = ["dep:smallvec", "octseq/smallvec"] -std = ["alloc", "dep:hashbrown", "bumpalo?/std", "bytes?/std", "octseq/std", "jiff/std", "serde?/std"] +std = ["alloc", "bumpalo?/std", "bytes?/std", "octseq/std", "jiff/std", "serde?/std"] tracing = ["dep:log", "dep:tracing"] # Cryptographic backends diff --git a/src/rdata/svcb/value.rs b/src/rdata/svcb/value.rs index d4022630..ab95f1b1 100644 --- a/src/rdata/svcb/value.rs +++ b/src/rdata/svcb/value.rs @@ -1,7 +1,7 @@ #[cfg(feature = "alloc")] use alloc::collections::BTreeSet; -#[cfg(feature = "std")] -use std::collections::HashSet; +#[cfg(feature = "alloc")] +use hashbrown::HashSet; use super::{ ComposeSvcParamValue, LongSvcParam, ParseSvcParamValue, PushError, @@ -140,7 +140,7 @@ macro_rules! values_enum { } } - #[cfg(feature = "std")] + #[cfg(feature = "alloc")] impl ScanSvcParamValue for AllValues where @@ -2012,7 +2012,7 @@ impl> TlsSupportedGroups { } } -#[cfg(feature = "std")] +#[cfg(feature = "alloc")] impl ScanSvcParamValue for TlsSupportedGroups where