Skip to content

Commit d73b3b2

Browse files
committed
Upgrade to 2018 edition
1 parent 2e94f9a commit d73b3b2

File tree

16 files changed

+237
-255
lines changed

16 files changed

+237
-255
lines changed

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ matrix:
1212
script:
1313
- cargo clean
1414
- cargo +nightly miri test
15-
- rust: 1.29.0
15+
- rust: 1.31.0
1616
- rust: stable
1717
- rust: beta
1818
- rust: nightly

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ readme = "README.md"
99
keywords = ["hash", "no_std", "hashmap", "swisstable"]
1010
categories = ["data-structures", "no-std"]
1111
exclude = [".travis.yml", "bors.toml"]
12+
edition = "2018"
1213

1314
[dependencies]
1415
# For external trait impls

benches/bench.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
#![feature(test)]
22

3-
extern crate hashbrown;
4-
extern crate rustc_hash;
53
extern crate test;
64

75
use std::hash::Hash;

src/external_trait_impls/rayon/map.rs

+40-44
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
//! Rayon extensions for `HashMap`.
22
3+
use crate::hash_map::HashMap;
34
use core::fmt;
45
use core::hash::{BuildHasher, Hash};
5-
use hash_map::HashMap;
66
use rayon::iter::plumbing::UnindexedConsumer;
77
use rayon::iter::{FromParallelIterator, IntoParallelIterator, ParallelExtend, ParallelIterator};
88

@@ -15,7 +15,7 @@ use rayon::iter::{FromParallelIterator, IntoParallelIterator, ParallelExtend, Pa
1515
/// [`par_iter`]: /hashbrown/struct.HashMap.html#method.par_iter
1616
/// [`HashMap`]: /hashbrown/struct.HashMap.html
1717
/// [`IntoParallelRefIterator`]: https://docs.rs/rayon/1.0/rayon/iter/trait.IntoParallelRefIterator.html
18-
pub struct ParIter<'a, K: 'a, V: 'a, S: 'a> {
18+
pub struct ParIter<'a, K, V, S> {
1919
map: &'a HashMap<K, V, S>,
2020
}
2121

@@ -38,17 +38,15 @@ impl<'a, K: Sync, V: Sync, S: Sync> ParallelIterator for ParIter<'a, K, V, S> {
3838
}
3939
}
4040

41-
impl<'a, K, V, S> Clone for ParIter<'a, K, V, S> {
41+
impl<K, V, S> Clone for ParIter<'_, K, V, S> {
4242
#[inline]
4343
fn clone(&self) -> Self {
4444
ParIter { map: self.map }
4545
}
4646
}
4747

48-
impl<'a, K: fmt::Debug + Eq + Hash, V: fmt::Debug, S: BuildHasher> fmt::Debug
49-
for ParIter<'a, K, V, S>
50-
{
51-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
48+
impl<K: fmt::Debug + Eq + Hash, V: fmt::Debug, S: BuildHasher> fmt::Debug for ParIter<'_, K, V, S> {
49+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
5250
self.map.iter().fmt(f)
5351
}
5452
}
@@ -60,7 +58,7 @@ impl<'a, K: fmt::Debug + Eq + Hash, V: fmt::Debug, S: BuildHasher> fmt::Debug
6058
///
6159
/// [`par_keys`]: /hashbrown/struct.HashMap.html#method.par_keys
6260
/// [`HashMap`]: /hashbrown/struct.HashMap.html
63-
pub struct ParKeys<'a, K: 'a, V: 'a, S: 'a> {
61+
pub struct ParKeys<'a, K, V, S> {
6462
map: &'a HashMap<K, V, S>,
6563
}
6664

@@ -80,15 +78,15 @@ impl<'a, K: Sync, V: Sync, S: Sync> ParallelIterator for ParKeys<'a, K, V, S> {
8078
}
8179
}
8280

83-
impl<'a, K, V, S> Clone for ParKeys<'a, K, V, S> {
81+
impl<K, V, S> Clone for ParKeys<'_, K, V, S> {
8482
#[inline]
8583
fn clone(&self) -> Self {
8684
ParKeys { map: self.map }
8785
}
8886
}
8987

90-
impl<'a, K: fmt::Debug + Eq + Hash, V, S: BuildHasher> fmt::Debug for ParKeys<'a, K, V, S> {
91-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
88+
impl<K: fmt::Debug + Eq + Hash, V, S: BuildHasher> fmt::Debug for ParKeys<'_, K, V, S> {
89+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
9290
self.map.keys().fmt(f)
9391
}
9492
}
@@ -100,7 +98,7 @@ impl<'a, K: fmt::Debug + Eq + Hash, V, S: BuildHasher> fmt::Debug for ParKeys<'a
10098
///
10199
/// [`par_values`]: /hashbrown/struct.HashMap.html#method.par_values
102100
/// [`HashMap`]: /hashbrown/struct.HashMap.html
103-
pub struct ParValues<'a, K: 'a, V: 'a, S: 'a> {
101+
pub struct ParValues<'a, K, V, S> {
104102
map: &'a HashMap<K, V, S>,
105103
}
106104

@@ -120,15 +118,15 @@ impl<'a, K: Sync, V: Sync, S: Sync> ParallelIterator for ParValues<'a, K, V, S>
120118
}
121119
}
122120

123-
impl<'a, K, V, S> Clone for ParValues<'a, K, V, S> {
121+
impl<K, V, S> Clone for ParValues<'_, K, V, S> {
124122
#[inline]
125123
fn clone(&self) -> Self {
126124
ParValues { map: self.map }
127125
}
128126
}
129127

130-
impl<'a, K: Eq + Hash, V: fmt::Debug, S: BuildHasher> fmt::Debug for ParValues<'a, K, V, S> {
131-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
128+
impl<K: Eq + Hash, V: fmt::Debug, S: BuildHasher> fmt::Debug for ParValues<'_, K, V, S> {
129+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
132130
self.map.values().fmt(f)
133131
}
134132
}
@@ -142,7 +140,7 @@ impl<'a, K: Eq + Hash, V: fmt::Debug, S: BuildHasher> fmt::Debug for ParValues<'
142140
/// [`par_iter_mut`]: /hashbrown/struct.HashMap.html#method.par_iter_mut
143141
/// [`HashMap`]: /hashbrown/struct.HashMap.html
144142
/// [`IntoParallelRefMutIterator`]: https://docs.rs/rayon/1.0/rayon/iter/trait.IntoParallelRefMutIterator.html
145-
pub struct ParIterMut<'a, K: 'a, V: 'a, S: 'a> {
143+
pub struct ParIterMut<'a, K, V, S> {
146144
map: &'a mut HashMap<K, V, S>,
147145
}
148146

@@ -165,10 +163,10 @@ impl<'a, K: Send + Sync, V: Send, S: Send> ParallelIterator for ParIterMut<'a, K
165163
}
166164
}
167165

168-
impl<'a, K: fmt::Debug + Eq + Hash, V: fmt::Debug, S: BuildHasher> fmt::Debug
169-
for ParIterMut<'a, K, V, S>
166+
impl<K: fmt::Debug + Eq + Hash, V: fmt::Debug, S: BuildHasher> fmt::Debug
167+
for ParIterMut<'_, K, V, S>
170168
{
171-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
169+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
172170
self.map.iter().fmt(f)
173171
}
174172
}
@@ -180,7 +178,7 @@ impl<'a, K: fmt::Debug + Eq + Hash, V: fmt::Debug, S: BuildHasher> fmt::Debug
180178
///
181179
/// [`par_values_mut`]: /hashbrown/struct.HashMap.html#method.par_values_mut
182180
/// [`HashMap`]: /hashbrown/struct.HashMap.html
183-
pub struct ParValuesMut<'a, K: 'a, V: 'a, S: 'a> {
181+
pub struct ParValuesMut<'a, K, V, S> {
184182
map: &'a mut HashMap<K, V, S>,
185183
}
186184

@@ -200,8 +198,8 @@ impl<'a, K: Send, V: Send, S: Send> ParallelIterator for ParValuesMut<'a, K, V,
200198
}
201199
}
202200

203-
impl<'a, K: Eq + Hash, V: fmt::Debug, S: BuildHasher> fmt::Debug for ParValuesMut<'a, K, V, S> {
204-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
201+
impl<K: Eq + Hash, V: fmt::Debug, S: BuildHasher> fmt::Debug for ParValuesMut<'_, K, V, S> {
202+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
205203
self.map.values().fmt(f)
206204
}
207205
}
@@ -231,10 +229,8 @@ impl<K: Send, V: Send, S: Send> ParallelIterator for IntoParIter<K, V, S> {
231229
}
232230
}
233231

234-
impl<'a, K: fmt::Debug + Eq + Hash, V: fmt::Debug, S: BuildHasher> fmt::Debug
235-
for IntoParIter<K, V, S>
236-
{
237-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
232+
impl<K: fmt::Debug + Eq + Hash, V: fmt::Debug, S: BuildHasher> fmt::Debug for IntoParIter<K, V, S> {
233+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
238234
self.map.iter().fmt(f)
239235
}
240236
}
@@ -246,11 +242,11 @@ impl<'a, K: fmt::Debug + Eq + Hash, V: fmt::Debug, S: BuildHasher> fmt::Debug
246242
///
247243
/// [`par_drain`]: /hashbrown/struct.HashMap.html#method.par_drain
248244
/// [`HashMap`]: /hashbrown/struct.HashMap.html
249-
pub struct ParDrain<'a, K: 'a, V: 'a, S: 'a> {
245+
pub struct ParDrain<'a, K, V, S> {
250246
map: &'a mut HashMap<K, V, S>,
251247
}
252248

253-
impl<'a, K: Send, V: Send, S: Send> ParallelIterator for ParDrain<'a, K, V, S> {
249+
impl<K: Send, V: Send, S: Send> ParallelIterator for ParDrain<'_, K, V, S> {
254250
type Item = (K, V);
255251

256252
#[inline]
@@ -262,39 +258,39 @@ impl<'a, K: Send, V: Send, S: Send> ParallelIterator for ParDrain<'a, K, V, S> {
262258
}
263259
}
264260

265-
impl<'a, K: fmt::Debug + Eq + Hash, V: fmt::Debug, S: BuildHasher> fmt::Debug
266-
for ParDrain<'a, K, V, S>
261+
impl<K: fmt::Debug + Eq + Hash, V: fmt::Debug, S: BuildHasher> fmt::Debug
262+
for ParDrain<'_, K, V, S>
267263
{
268-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
264+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
269265
self.map.iter().fmt(f)
270266
}
271267
}
272268

273269
impl<K: Sync, V: Sync, S: Sync> HashMap<K, V, S> {
274270
/// Visits (potentially in parallel) immutably borrowed keys in an arbitrary order.
275271
#[inline]
276-
pub fn par_keys(&self) -> ParKeys<K, V, S> {
272+
pub fn par_keys(&self) -> ParKeys<'_, K, V, S> {
277273
ParKeys { map: self }
278274
}
279275

280276
/// Visits (potentially in parallel) immutably borrowed values in an arbitrary order.
281277
#[inline]
282-
pub fn par_values(&self) -> ParValues<K, V, S> {
278+
pub fn par_values(&self) -> ParValues<'_, K, V, S> {
283279
ParValues { map: self }
284280
}
285281
}
286282

287283
impl<K: Send, V: Send, S: Send> HashMap<K, V, S> {
288284
/// Visits (potentially in parallel) mutably borrowed values in an arbitrary order.
289285
#[inline]
290-
pub fn par_values_mut(&mut self) -> ParValuesMut<K, V, S> {
286+
pub fn par_values_mut(&mut self) -> ParValuesMut<'_, K, V, S> {
291287
ParValuesMut { map: self }
292288
}
293289

294290
/// Consumes (potentially in parallel) all values in an arbitrary order,
295291
/// while preserving the map's allocated memory for reuse.
296292
#[inline]
297-
pub fn par_drain(&mut self) -> ParDrain<K, V, S> {
293+
pub fn par_drain(&mut self) -> ParDrain<'_, K, V, S> {
298294
ParDrain { map: self }
299295
}
300296
}
@@ -426,34 +422,34 @@ mod test_par_map {
426422

427423
use rayon::prelude::*;
428424

429-
use hash_map::HashMap;
425+
use crate::hash_map::HashMap;
430426

431427
struct Dropable<'a> {
432428
k: usize,
433429
counter: &'a AtomicUsize,
434430
}
435431

436-
impl<'a> Dropable<'a> {
437-
fn new(k: usize, counter: &AtomicUsize) -> Dropable {
432+
impl Dropable<'_> {
433+
fn new(k: usize, counter: &AtomicUsize) -> Dropable<'_> {
438434
counter.fetch_add(1, Ordering::Relaxed);
439435

440436
Dropable { k, counter }
441437
}
442438
}
443439

444-
impl<'a> Drop for Dropable<'a> {
440+
impl Drop for Dropable<'_> {
445441
fn drop(&mut self) {
446442
self.counter.fetch_sub(1, Ordering::Relaxed);
447443
}
448444
}
449445

450-
impl<'a> Clone for Dropable<'a> {
451-
fn clone(&self) -> Dropable<'a> {
446+
impl Clone for Dropable<'_> {
447+
fn clone(&self) -> Self {
452448
Dropable::new(self.k, self.counter)
453449
}
454450
}
455451

456-
impl<'a> Hash for Dropable<'a> {
452+
impl Hash for Dropable<'_> {
457453
fn hash<H>(&self, state: &mut H)
458454
where
459455
H: Hasher,
@@ -462,13 +458,13 @@ mod test_par_map {
462458
}
463459
}
464460

465-
impl<'a> PartialEq for Dropable<'a> {
461+
impl PartialEq for Dropable<'_> {
466462
fn eq(&self, other: &Self) -> bool {
467463
self.k == other.k
468464
}
469465
}
470466

471-
impl<'a> Eq for Dropable<'a> {}
467+
impl Eq for Dropable<'_> {}
472468

473469
#[test]
474470
fn test_into_iter_drops() {

src/external_trait_impls/rayon/raw.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1+
use crate::raw::Bucket;
2+
use crate::raw::{RawIterRange, RawTable};
3+
use crate::scopeguard::guard;
14
use alloc::alloc::dealloc;
25
use core::marker::PhantomData;
36
use core::mem;
47
use core::ptr::NonNull;
5-
use raw::Bucket;
6-
use raw::{RawIterRange, RawTable};
78
use rayon::iter::{
89
plumbing::{self, Folder, UnindexedConsumer, UnindexedProducer},
910
ParallelIterator,
1011
};
11-
use scopeguard::guard;
1212

1313
/// Parallel iterator which returns a raw pointer to every full bucket in the table.
1414
pub struct RawParIter<T> {
@@ -87,9 +87,9 @@ pub struct RawParDrain<'a, T> {
8787
_marker: PhantomData<&'a RawTable<T>>,
8888
}
8989

90-
unsafe impl<'a, T> Send for RawParDrain<'a, T> {}
90+
unsafe impl<T> Send for RawParDrain<'_, T> {}
9191

92-
impl<'a, T: Send> ParallelIterator for RawParDrain<'a, T> {
92+
impl<T: Send> ParallelIterator for RawParDrain<'_, T> {
9393
type Item = T;
9494

9595
#[inline]
@@ -107,7 +107,7 @@ impl<'a, T: Send> ParallelIterator for RawParDrain<'a, T> {
107107
}
108108
}
109109

110-
impl<'a, T> Drop for RawParDrain<'a, T> {
110+
impl<T> Drop for RawParDrain<'_, T> {
111111
fn drop(&mut self) {
112112
// If drive_unindexed is not called then simply clear the table.
113113
unsafe { self.table.as_mut().clear() }
@@ -184,7 +184,7 @@ impl<T> RawTable<T> {
184184
/// Returns a parallel iterator which consumes all elements of a `RawTable`
185185
/// without freeing its memory allocation.
186186
#[inline]
187-
pub fn par_drain(&mut self) -> RawParDrain<T> {
187+
pub fn par_drain(&mut self) -> RawParDrain<'_, T> {
188188
RawParDrain {
189189
table: NonNull::from(self),
190190
_marker: PhantomData,

0 commit comments

Comments
 (0)