Skip to content

Commit 067e406

Browse files
authored
feat: update to rustc-hash 2 (#17)
1 parent ed502ea commit 067e406

File tree

4 files changed

+98
-62
lines changed

4 files changed

+98
-62
lines changed

Cargo.lock

Lines changed: 88 additions & 52 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "metainfo"
3-
version = "0.7.11"
3+
version = "0.7.12"
44
authors = ["Volo Team <volo@cloudwego.io>"]
55
edition = "2021"
66
description = "Transmissing metainfo across components."
@@ -17,7 +17,7 @@ maintenance = { status = "actively-developed" }
1717
[dependencies]
1818
ahash = "0.8"
1919
faststr = "0.2"
20-
rustc-hash = "1"
20+
rustc-hash = { version = "2", features = ["rand"] }
2121
paste = "1"
2222
tokio = { version = "1", optional = true }
2323

src/faststr_map.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
use std::{any::TypeId, collections::hash_map::Entry};
22

33
use faststr::FastStr;
4-
use rustc_hash::FxHashMap;
4+
use rustc_hash::FxHashMapRand;
55

66
/// This is an optimized version of TypeMap to FastStr that eliminates the need to Box the values.
77
///
88
/// This map is suitable for T that impls both From<FastStr> and Into<FastStr>.
99
#[derive(Debug, Default)]
1010
pub struct FastStrMap {
11-
inner: FxHashMap<TypeId, FastStr>,
11+
inner: FxHashMapRand<TypeId, FastStr>,
1212
}
1313

1414
impl FastStrMap {
1515
#[inline]
1616
pub fn new() -> Self {
1717
Self {
18-
inner: FxHashMap::default(),
18+
inner: FxHashMapRand::default(),
1919
}
2020
}
2121

2222
#[inline]
2323
pub fn with_capacity(capacity: usize) -> Self {
2424
Self {
25-
inner: FxHashMap::with_capacity_and_hasher(capacity, Default::default()),
25+
inner: FxHashMapRand::with_capacity_and_hasher(capacity, Default::default()),
2626
}
2727
}
2828

src/type_map.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::{
44
marker::PhantomData,
55
};
66

7-
use rustc_hash::FxHashMap;
7+
use rustc_hash::FxHashMapRand;
88

99
pub(crate) type AnyObject = Box<dyn Any + Send + Sync>;
1010

@@ -66,21 +66,21 @@ impl<'a, K, V> Entry<'a, K, V> {
6666

6767
#[derive(Debug, Default)]
6868
pub struct TypeMap {
69-
inner: FxHashMap<TypeId, AnyObject>,
69+
inner: FxHashMapRand<TypeId, AnyObject>,
7070
}
7171

7272
impl TypeMap {
7373
#[inline]
7474
pub fn new() -> Self {
7575
TypeMap {
76-
inner: FxHashMap::default(),
76+
inner: FxHashMapRand::default(),
7777
}
7878
}
7979

8080
#[inline]
8181
pub fn with_capacity(capacity: usize) -> Self {
8282
TypeMap {
83-
inner: FxHashMap::with_capacity_and_hasher(capacity, Default::default()),
83+
inner: FxHashMapRand::with_capacity_and_hasher(capacity, Default::default()),
8484
}
8585
}
8686

0 commit comments

Comments
 (0)