Skip to content

Commit 041ee54

Browse files
authored
Merge pull request #138 from cuviper/2018
Upgrade to 2018 edition
2 parents d293267 + e8c7789 commit 041ee54

20 files changed

+172
-222
lines changed

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
[package]
22
name = "indexmap"
3+
edition = "2018"
34
version = "1.5.0"
45
authors = [
56
"bluss",

benches/bench.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#![feature(test)]
2-
extern crate fnv;
3-
extern crate rand;
2+
43
extern crate test;
54
#[macro_use]
65
extern crate lazy_static;
@@ -13,8 +12,6 @@ type FnvBuilder = BuildHasherDefault<FnvHasher>;
1312
use test::black_box;
1413
use test::Bencher;
1514

16-
extern crate indexmap;
17-
1815
use indexmap::IndexMap;
1916

2017
use std::collections::HashMap;

benches/faststring.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
#![feature(test)]
2-
extern crate lazy_static;
3-
extern crate rand;
2+
43
extern crate test;
54

65
use test::Bencher;
76

8-
extern crate indexmap;
9-
107
use indexmap::IndexMap;
118

129
use std::collections::HashMap;

build.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
extern crate autocfg;
2-
31
fn main() {
42
let ac = autocfg::new();
53
ac.emit_sysroot_crate("std");

src/equivalent.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::borrow::Borrow;
1+
use core::borrow::Borrow;
22

33
/// Key equivalence trait.
44
///

src/lib.rs

+11-19
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
// We *mostly* avoid unsafe code, but `map::core::raw` allows it to use `RawTable` buckets.
22
#![deny(unsafe_code)]
3+
#![warn(rust_2018_idioms)]
34
#![doc(html_root_url = "https://docs.rs/indexmap/1/")]
4-
#![cfg_attr(not(has_std), no_std)]
5+
#![no_std]
56

67
//! [`IndexMap`] is a hash table where the iteration order of the key-value
78
//! pairs is independent of the hash values of the keys.
@@ -33,8 +34,6 @@
3334
//! to use alternate hashers:
3435
//!
3536
//! ```
36-
//! # extern crate fnv;
37-
//! # extern crate fxhash;
3837
//! use fnv::FnvBuildHasher;
3938
//! use fxhash::FxBuildHasher;
4039
//! use indexmap::{IndexMap, IndexSet};
@@ -82,22 +81,15 @@
8281
#[cfg(not(has_std))]
8382
extern crate alloc;
8483

85-
extern crate hashbrown;
84+
#[cfg(has_std)]
85+
#[macro_use]
86+
extern crate std;
8687

8788
#[cfg(not(has_std))]
88-
pub(crate) mod std {
89-
pub use core::*;
90-
pub mod alloc {
91-
pub use alloc::*;
92-
}
93-
pub mod collections {
94-
pub use alloc::collections::*;
95-
}
96-
pub use alloc::vec;
97-
}
89+
use alloc::vec::{self, Vec};
9890

99-
#[cfg(not(has_std))]
100-
use std::vec::Vec;
91+
#[cfg(has_std)]
92+
use std::vec::{self, Vec};
10193

10294
#[macro_use]
10395
mod macros;
@@ -115,9 +107,9 @@ pub mod set;
115107
#[cfg(feature = "rayon")]
116108
mod rayon;
117109

118-
pub use equivalent::Equivalent;
119-
pub use map::IndexMap;
120-
pub use set::IndexSet;
110+
pub use crate::equivalent::Equivalent;
111+
pub use crate::map::IndexMap;
112+
pub use crate::set::IndexSet;
121113

122114
// shared private items
123115

src/macros.rs

+10-14
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
#[cfg(has_std)]
2-
#[macro_export(local_inner_macros)]
2+
#[macro_export]
33
/// Create an `IndexMap` from a list of key-value pairs
44
///
55
/// ## Example
66
///
77
/// ```
8-
/// #[macro_use] extern crate indexmap;
9-
/// # fn main() {
8+
/// use indexmap::indexmap;
109
///
1110
/// let map = indexmap!{
1211
/// "a" => 1,
@@ -18,16 +17,15 @@
1817
///
1918
/// // "a" is the first key
2019
/// assert_eq!(map.keys().next(), Some(&"a"));
21-
/// # }
2220
/// ```
2321
macro_rules! indexmap {
2422
(@single $($x:tt)*) => (());
25-
(@count $($rest:expr),*) => (<[()]>::len(&[$(indexmap!(@single $rest)),*]));
23+
(@count $($rest:expr),*) => (<[()]>::len(&[$($crate::indexmap!(@single $rest)),*]));
2624

27-
($($key:expr => $value:expr,)+) => { indexmap!($($key => $value),+) };
25+
($($key:expr => $value:expr,)+) => { $crate::indexmap!($($key => $value),+) };
2826
($($key:expr => $value:expr),*) => {
2927
{
30-
let _cap = indexmap!(@count $($key),*);
28+
let _cap = $crate::indexmap!(@count $($key),*);
3129
let mut _map = $crate::IndexMap::with_capacity(_cap);
3230
$(
3331
_map.insert($key, $value);
@@ -38,14 +36,13 @@ macro_rules! indexmap {
3836
}
3937

4038
#[cfg(has_std)]
41-
#[macro_export(local_inner_macros)]
39+
#[macro_export]
4240
/// Create an `IndexSet` from a list of values
4341
///
4442
/// ## Example
4543
///
4644
/// ```
47-
/// #[macro_use] extern crate indexmap;
48-
/// # fn main() {
45+
/// use indexmap::indexset;
4946
///
5047
/// let set = indexset!{
5148
/// "a",
@@ -57,16 +54,15 @@ macro_rules! indexmap {
5754
///
5855
/// // "a" is the first value
5956
/// assert_eq!(set.iter().next(), Some(&"a"));
60-
/// # }
6157
/// ```
6258
macro_rules! indexset {
6359
(@single $($x:tt)*) => (());
64-
(@count $($rest:expr),*) => (<[()]>::len(&[$(indexset!(@single $rest)),*]));
60+
(@count $($rest:expr),*) => (<[()]>::len(&[$($crate::indexset!(@single $rest)),*]));
6561

66-
($($value:expr,)+) => { indexset!($($value),+) };
62+
($($value:expr,)+) => { $crate::indexset!($($value),+) };
6763
($($value:expr),*) => {
6864
{
69-
let _cap = indexset!(@count $($value),*);
65+
let _cap = $crate::indexset!(@count $($value),*);
7066
let mut _set = $crate::IndexSet::with_capacity(_cap);
7167
$(
7268
_set.insert($value);

0 commit comments

Comments
 (0)