Skip to content

Commit 86413e7

Browse files
committed
Run rustfmt on util/hash_tables.rs
.. to fix the silent rebase conflict.
1 parent 8051234 commit 86413e7

File tree

1 file changed

+38
-13
lines changed

1 file changed

+38
-13
lines changed

lightning/src/util/hash_tables.rs

+38-13
Original file line numberDiff line numberDiff line change
@@ -15,31 +15,43 @@ extern crate possiblyrandom;
1515

1616
#[cfg(not(feature = "hashbrown"))]
1717
mod std_hashtables {
18-
pub use std::collections::HashMap;
1918
pub use std::collections::hash_map::RandomState;
19+
pub use std::collections::HashMap;
2020

21-
pub(crate) use std::collections::{HashSet, hash_map};
21+
pub(crate) use std::collections::{hash_map, HashSet};
2222

2323
pub(crate) type OccupiedHashMapEntry<'a, K, V> =
2424
std::collections::hash_map::OccupiedEntry<'a, K, V>;
2525
pub(crate) type VacantHashMapEntry<'a, K, V> =
2626
std::collections::hash_map::VacantEntry<'a, K, V>;
2727

2828
/// Builds a new [`HashMap`].
29-
pub fn new_hash_map<K, V>() -> HashMap<K, V> { HashMap::new() }
29+
pub fn new_hash_map<K, V>() -> HashMap<K, V> {
30+
HashMap::new()
31+
}
3032
/// Builds a new [`HashMap`] with the given capacity.
3133
pub fn hash_map_with_capacity<K, V>(cap: usize) -> HashMap<K, V> {
3234
HashMap::with_capacity(cap)
3335
}
34-
pub(crate) fn hash_map_from_iter<K: core::hash::Hash + Eq, V, I: IntoIterator<Item=(K, V)>>(iter: I) -> HashMap<K, V> {
36+
pub(crate) fn hash_map_from_iter<
37+
K: core::hash::Hash + Eq,
38+
V,
39+
I: IntoIterator<Item = (K, V)>,
40+
>(
41+
iter: I,
42+
) -> HashMap<K, V> {
3543
HashMap::from_iter(iter)
3644
}
3745

38-
pub(crate) fn new_hash_set<K>() -> HashSet<K> { HashSet::new() }
46+
pub(crate) fn new_hash_set<K>() -> HashSet<K> {
47+
HashSet::new()
48+
}
3949
pub(crate) fn hash_set_with_capacity<K>(cap: usize) -> HashSet<K> {
4050
HashSet::with_capacity(cap)
4151
}
42-
pub(crate) fn hash_set_from_iter<K: core::hash::Hash + Eq, I: IntoIterator<Item=K>>(iter: I) -> HashSet<K> {
52+
pub(crate) fn hash_set_from_iter<K: core::hash::Hash + Eq, I: IntoIterator<Item = K>>(
53+
iter: I,
54+
) -> HashSet<K> {
4355
HashSet::from_iter(iter)
4456
}
4557
}
@@ -64,15 +76,17 @@ mod hashbrown_tables {
6476
/// A simple implementation of [`BuildHasher`] that uses `getrandom` to opportunistically
6577
/// randomize, if the platform supports it.
6678
pub struct RandomState {
67-
k0: u64, k1: u64,
79+
k0: u64,
80+
k1: u64,
6881
}
6982

7083
impl RandomState {
7184
/// Constructs a new [`RandomState`] which may or may not be random, depending on the
7285
/// target platform.
7386
pub fn new() -> RandomState {
7487
let (k0, k1);
75-
#[cfg(all(not(fuzzing), feature = "possiblyrandom"))] {
88+
#[cfg(all(not(fuzzing), feature = "possiblyrandom"))]
89+
{
7690
let mut keys = [0; 16];
7791
possiblyrandom::getpossiblyrandom(&mut keys);
7892

@@ -83,7 +97,8 @@ mod hashbrown_tables {
8397
k0 = u64::from_le_bytes(k0_bytes);
8498
k1 = u64::from_le_bytes(k1_bytes);
8599
}
86-
#[cfg(any(fuzzing, not(feature = "possiblyrandom")))] {
100+
#[cfg(any(fuzzing, not(feature = "possiblyrandom")))]
101+
{
87102
k0 = 0;
88103
k1 = 0;
89104
}
@@ -92,7 +107,9 @@ mod hashbrown_tables {
92107
}
93108

94109
impl Default for RandomState {
95-
fn default() -> RandomState { RandomState::new() }
110+
fn default() -> RandomState {
111+
RandomState::new()
112+
}
96113
}
97114

98115
impl BuildHasher for RandomState {
@@ -103,8 +120,8 @@ mod hashbrown_tables {
103120
}
104121
}
105122

106-
pub use hasher::*;
107123
use super::*;
124+
pub use hasher::*;
108125

109126
/// The HashMap type used in LDK.
110127
pub type HashMap<K, V> = hashbrown::HashMap<K, V, RandomState>;
@@ -123,7 +140,13 @@ mod hashbrown_tables {
123140
pub fn hash_map_with_capacity<K, V>(cap: usize) -> HashMap<K, V> {
124141
HashMap::with_capacity_and_hasher(cap, RandomState::new())
125142
}
126-
pub(crate) fn hash_map_from_iter<K: core::hash::Hash + Eq, V, I: IntoIterator<Item=(K, V)>>(iter: I) -> HashMap<K, V> {
143+
pub(crate) fn hash_map_from_iter<
144+
K: core::hash::Hash + Eq,
145+
V,
146+
I: IntoIterator<Item = (K, V)>,
147+
>(
148+
iter: I,
149+
) -> HashMap<K, V> {
127150
let iter = iter.into_iter();
128151
let min_size = iter.size_hint().0;
129152
let mut res = HashMap::with_capacity_and_hasher(min_size, RandomState::new());
@@ -137,7 +160,9 @@ mod hashbrown_tables {
137160
pub(crate) fn hash_set_with_capacity<K>(cap: usize) -> HashSet<K> {
138161
HashSet::with_capacity_and_hasher(cap, RandomState::new())
139162
}
140-
pub(crate) fn hash_set_from_iter<K: core::hash::Hash + Eq, I: IntoIterator<Item=K>>(iter: I) -> HashSet<K> {
163+
pub(crate) fn hash_set_from_iter<K: core::hash::Hash + Eq, I: IntoIterator<Item = K>>(
164+
iter: I,
165+
) -> HashSet<K> {
141166
let iter = iter.into_iter();
142167
let min_size = iter.size_hint().0;
143168
let mut res = HashSet::with_capacity_and_hasher(min_size, RandomState::new());

0 commit comments

Comments
 (0)