Skip to content

Commit c83cc48

Browse files
bors[bot]orium
andauthored
Merge #416
416: Migration to 2018 edition. r=jswrenn a=orium Co-authored-by: Diogo Sousa <[email protected]>
2 parents 0b99893 + b3cd96a commit c83cc48

34 files changed

+106
-169
lines changed

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ keywords = ["iterator", "data-structure", "zip", "product", "group-by"]
1313
categories = ["algorithms", "rust-patterns"]
1414
exclude = ["/bors.toml"]
1515

16+
edition = "2018"
17+
1618
[package.metadata.release]
1719
no-dev-version = true
1820

README.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ How to use in your crate:
2727

2828
.. code:: rust
2929
30-
#[macro_use] extern crate itertools;
31-
3230
use itertools::Itertools;
3331
3432
How to contribute

benches/bench1.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
1-
extern crate criterion;
2-
#[macro_use] extern crate itertools;
3-
41
use criterion::{black_box, criterion_group, criterion_main, Criterion};
52
use itertools::Itertools;
63
use itertools::free::cloned;
4+
use itertools::iproduct;
75

86
use std::iter::repeat;
97
use std::cmp;
108
use std::ops::{Add, Range};
119

1210
mod extra;
1311

14-
use extra::ZipSlices;
12+
use crate::extra::ZipSlices;
1513

1614
fn slice_iter(c: &mut Criterion) {
1715
let xs: Vec<_> = repeat(1i32).take(20).collect();

benches/combinations_with_replacement.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
extern crate criterion;
2-
extern crate itertools;
3-
41
use criterion::{black_box, criterion_group, criterion_main, Criterion};
52
use itertools::Itertools;
63

benches/fold_specialization.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
extern crate criterion;
2-
extern crate itertools;
3-
41
use criterion::{criterion_group, criterion_main, Criterion};
52
use itertools::Itertools;
63

benches/tree_fold1.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
extern crate criterion;
2-
extern crate itertools;
3-
41
use criterion::{criterion_group, criterion_main, Criterion};
52
use itertools::{Itertools, cloned};
63

benches/tuple_combinations.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
extern crate criterion;
2-
extern crate itertools;
3-
41
use criterion::{black_box, criterion_group, criterion_main, Criterion};
52
use itertools::Itertools;
63

benches/tuples.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
extern crate criterion;
2-
extern crate itertools;
3-
41
use criterion::{criterion_group, criterion_main, Criterion};
52
use itertools::Itertools;
63

examples/iris.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@
33
/// and does some simple manipulations.
44
///
55
/// Iterators and itertools functionality are used throughout.
6-
///
7-
///
8-
9-
extern crate itertools;
106
117
use itertools::Itertools;
128
use std::collections::HashMap;

src/adaptors/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use std::fmt;
1212
use std::mem::replace;
1313
use std::iter::{Fuse, Peekable, FromIterator};
1414
use std::marker::PhantomData;
15-
use size_hint;
15+
use crate::size_hint;
1616

1717
/// An iterator adaptor that alternates elements from two iterators until both
1818
/// run out.

src/adaptors/multi_product.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#![cfg(feature = "use_std")]
22

3-
use size_hint;
4-
use Itertools;
3+
use crate::size_hint;
4+
use crate::Itertools;
55

66
#[derive(Clone)]
77
/// An iterator adaptor that iterates over the cartesian product of

src/concat_impl.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use Itertools;
1+
use crate::Itertools;
22

33
/// Combine all an iterator's elements into one element by using `Extend`.
44
///

src/diff.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
//! describes the difference between two non-`Clone` iterators `I` and `J` after breaking ASAP from
66
//! a lock-step comparison.
77
8-
use free::put_back;
9-
use structs::PutBack;
8+
use crate::free::put_back;
9+
use crate::structs::PutBack;
1010

1111
/// A type returned by the [`diff_with`](./fn.diff_with.html) function.
1212
///

src/either_or_both.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use EitherOrBoth::*;
1+
use crate::EitherOrBoth::*;
22

33
use either::Either;
44

src/exactly_one_err.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::iter::ExactSizeIterator;
22

3-
use size_hint;
3+
use crate::size_hint;
44

55
/// Iterator returned for the error case of `IterTools::exactly_one()`
66
/// This iterator yields exactly the same elements as the input iterator.

src/free.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,23 @@ use std::iter::{self, Zip};
1010
type VecIntoIter<T> = ::std::vec::IntoIter<T>;
1111

1212
#[cfg(feature = "use_std")]
13-
use Itertools;
13+
use crate::Itertools;
1414

15-
pub use adaptors::{
15+
pub use crate::adaptors::{
1616
interleave,
1717
merge,
1818
put_back,
1919
};
2020
#[cfg(feature = "use_std")]
21-
pub use put_back_n_impl::put_back_n;
21+
pub use crate::put_back_n_impl::put_back_n;
2222
#[cfg(feature = "use_std")]
23-
pub use multipeek_impl::multipeek;
23+
pub use crate::multipeek_impl::multipeek;
2424
#[cfg(feature = "use_std")]
25-
pub use kmerge_impl::kmerge;
26-
pub use zip_eq_impl::zip_eq;
27-
pub use merge_join::merge_join_by;
25+
pub use crate::kmerge_impl::kmerge;
26+
pub use crate::zip_eq_impl::zip_eq;
27+
pub use crate::merge_join::merge_join_by;
2828
#[cfg(feature = "use_std")]
29-
pub use rciter_impl::rciter;
29+
pub use crate::rciter_impl::rciter;
3030

3131
/// Iterate `iterable` with a running index.
3232
///

src/kmerge_impl.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
2-
use size_hint;
3-
use Itertools;
1+
use crate::size_hint;
2+
use crate::Itertools;
43

54
use std::mem::replace;
65
use std::fmt;

src/lib.rs

Lines changed: 51 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@
4747
//! [`Iterator`]: https://doc.rust-lang.org/std/iter/trait.Iterator.html
4848
#![doc(html_root_url="https://docs.rs/itertools/0.8/")]
4949

50-
extern crate either;
51-
5250
#[cfg(not(feature = "use_std"))]
5351
extern crate core as std;
5452

@@ -77,7 +75,7 @@ pub use std::iter as __std_iter;
7775

7876
/// The concrete iterator types.
7977
pub mod structs {
80-
pub use adaptors::{
78+
pub use crate::adaptors::{
8179
Dedup,
8280
DedupBy,
8381
Interleave,
@@ -97,75 +95,75 @@ pub mod structs {
9795
Update,
9896
};
9997
#[allow(deprecated)]
100-
pub use adaptors::Step;
98+
pub use crate::adaptors::Step;
10199
#[cfg(feature = "use_std")]
102-
pub use adaptors::MultiProduct;
100+
pub use crate::adaptors::MultiProduct;
103101
#[cfg(feature = "use_std")]
104-
pub use combinations::Combinations;
102+
pub use crate::combinations::Combinations;
105103
#[cfg(feature = "use_std")]
106-
pub use combinations_with_replacement::CombinationsWithReplacement;
107-
pub use cons_tuples_impl::ConsTuples;
108-
pub use exactly_one_err::ExactlyOneError;
109-
pub use format::{Format, FormatWith};
104+
pub use crate::combinations_with_replacement::CombinationsWithReplacement;
105+
pub use crate::cons_tuples_impl::ConsTuples;
106+
pub use crate::exactly_one_err::ExactlyOneError;
107+
pub use crate::format::{Format, FormatWith};
110108
#[cfg(feature = "use_std")]
111-
pub use groupbylazy::{IntoChunks, Chunk, Chunks, GroupBy, Group, Groups};
112-
pub use intersperse::Intersperse;
109+
pub use crate::groupbylazy::{IntoChunks, Chunk, Chunks, GroupBy, Group, Groups};
110+
pub use crate::intersperse::Intersperse;
113111
#[cfg(feature = "use_std")]
114-
pub use kmerge_impl::{KMerge, KMergeBy};
115-
pub use merge_join::MergeJoinBy;
112+
pub use crate::kmerge_impl::{KMerge, KMergeBy};
113+
pub use crate::merge_join::MergeJoinBy;
116114
#[cfg(feature = "use_std")]
117-
pub use multipeek_impl::MultiPeek;
118-
pub use pad_tail::PadUsing;
119-
pub use peeking_take_while::PeekingTakeWhile;
115+
pub use crate::multipeek_impl::MultiPeek;
116+
pub use crate::pad_tail::PadUsing;
117+
pub use crate::peeking_take_while::PeekingTakeWhile;
120118
#[cfg(feature = "use_std")]
121-
pub use permutations::Permutations;
122-
pub use process_results_impl::ProcessResults;
119+
pub use crate::permutations::Permutations;
120+
pub use crate::process_results_impl::ProcessResults;
123121
#[cfg(feature = "use_std")]
124-
pub use put_back_n_impl::PutBackN;
122+
pub use crate::put_back_n_impl::PutBackN;
125123
#[cfg(feature = "use_std")]
126-
pub use rciter_impl::RcIter;
127-
pub use repeatn::RepeatN;
124+
pub use crate::rciter_impl::RcIter;
125+
pub use crate::repeatn::RepeatN;
128126
#[allow(deprecated)]
129-
pub use sources::{RepeatCall, Unfold, Iterate};
127+
pub use crate::sources::{RepeatCall, Unfold, Iterate};
130128
#[cfg(feature = "use_std")]
131-
pub use tee::Tee;
132-
pub use tuple_impl::{TupleBuffer, TupleWindows, Tuples};
129+
pub use crate::tee::Tee;
130+
pub use crate::tuple_impl::{TupleBuffer, TupleWindows, Tuples};
133131
#[cfg(feature = "use_std")]
134-
pub use unique_impl::{Unique, UniqueBy};
135-
pub use with_position::WithPosition;
136-
pub use zip_eq_impl::ZipEq;
137-
pub use zip_longest::ZipLongest;
138-
pub use ziptuple::Zip;
132+
pub use crate::unique_impl::{Unique, UniqueBy};
133+
pub use crate::with_position::WithPosition;
134+
pub use crate::zip_eq_impl::ZipEq;
135+
pub use crate::zip_longest::ZipLongest;
136+
pub use crate::ziptuple::Zip;
139137
}
140138

141139
/// Traits helpful for using certain `Itertools` methods in generic contexts.
142140
pub mod traits {
143-
pub use ::tuple_impl::HomogeneousTuple;
141+
pub use crate::tuple_impl::HomogeneousTuple;
144142
}
145143

146144
#[allow(deprecated)]
147-
pub use structs::*;
148-
pub use concat_impl::concat;
149-
pub use cons_tuples_impl::cons_tuples;
150-
pub use diff::diff_with;
151-
pub use diff::Diff;
145+
pub use crate::structs::*;
146+
pub use crate::concat_impl::concat;
147+
pub use crate::cons_tuples_impl::cons_tuples;
148+
pub use crate::diff::diff_with;
149+
pub use crate::diff::Diff;
152150
#[cfg(feature = "use_std")]
153-
pub use kmerge_impl::{kmerge_by};
154-
pub use minmax::MinMaxResult;
155-
pub use peeking_take_while::PeekingNext;
156-
pub use process_results_impl::process_results;
157-
pub use repeatn::repeat_n;
151+
pub use crate::kmerge_impl::{kmerge_by};
152+
pub use crate::minmax::MinMaxResult;
153+
pub use crate::peeking_take_while::PeekingNext;
154+
pub use crate::process_results_impl::process_results;
155+
pub use crate::repeatn::repeat_n;
158156
#[allow(deprecated)]
159-
pub use sources::{repeat_call, unfold, iterate};
160-
pub use with_position::Position;
161-
pub use ziptuple::multizip;
157+
pub use crate::sources::{repeat_call, unfold, iterate};
158+
pub use crate::with_position::Position;
159+
pub use crate::ziptuple::multizip;
162160
mod adaptors;
163161
mod either_or_both;
164-
pub use either_or_both::EitherOrBoth;
162+
pub use crate::either_or_both::EitherOrBoth;
165163
#[doc(hidden)]
166164
pub mod free;
167165
#[doc(inline)]
168-
pub use free::*;
166+
pub use crate::free::*;
169167
mod concat_impl;
170168
mod cons_tuples_impl;
171169
#[cfg(feature = "use_std")]
@@ -217,7 +215,8 @@ mod ziptuple;
217215
/// from iterators `(I, J, ..., M)` with element types `I::Item = A`, `J::Item = B`, etc.
218216
///
219217
/// ```
220-
/// #[macro_use] extern crate itertools;
218+
/// # use itertools::iproduct;
219+
/// #
221220
/// # fn main() {
222221
/// // Iterate over the coordinates of a 4 x 4 x 4 grid
223222
/// // from (0, 0, 0), (0, 0, 1), .., (0, 1, 0), (0, 1, 1), .. etc until (3, 3, 3)
@@ -226,14 +225,6 @@ mod ziptuple;
226225
/// }
227226
/// # }
228227
/// ```
229-
///
230-
/// **Note:** To enable the macros in this crate, use the `#[macro_use]`
231-
/// attribute when importing the crate:
232-
///
233-
/// ```
234-
/// #[macro_use] extern crate itertools;
235-
/// # fn main() { }
236-
/// ```
237228
macro_rules! iproduct {
238229
(@flatten $I:expr,) => (
239230
$I
@@ -274,7 +265,8 @@ macro_rules! iproduct {
274265
/// [`multizip`]: fn.multizip.html
275266
///
276267
/// ```
277-
/// #[macro_use] extern crate itertools;
268+
/// # use itertools::izip;
269+
/// #
278270
/// # fn main() {
279271
///
280272
/// // iterate over three sequences side-by-side
@@ -288,14 +280,6 @@ macro_rules! iproduct {
288280
/// assert_eq!(results, [0 + 3, 10 + 7, 29, 36]);
289281
/// # }
290282
/// ```
291-
///
292-
/// **Note:** To enable the macros in this crate, use the `#[macro_use]`
293-
/// attribute when importing the crate:
294-
///
295-
/// ```
296-
/// #[macro_use] extern crate itertools;
297-
/// # fn main() { }
298-
/// ```
299283
macro_rules! izip {
300284
// @closure creates a tuple-flattening closure for .map() call. usage:
301285
// @closure partial_pattern => partial_tuple , rest , of , iterators
@@ -2467,7 +2451,7 @@ pub trait Itertools : Iterator {
24672451
fn position_minmax(self) -> MinMaxResult<usize>
24682452
where Self: Sized, Self::Item: PartialOrd
24692453
{
2470-
use MinMaxResult::{NoElements, OneElement, MinMax};
2454+
use crate::MinMaxResult::{NoElements, OneElement, MinMax};
24712455
match minmax::minmax_impl(self.enumerate(), |_| (), |x, y, _, _| x.1 < y.1) {
24722456
NoElements => NoElements,
24732457
OneElement(x) => OneElement(x.0),
@@ -2513,7 +2497,7 @@ pub trait Itertools : Iterator {
25132497
fn position_minmax_by_key<K, F>(self, mut key: F) -> MinMaxResult<usize>
25142498
where Self: Sized, K: PartialOrd, F: FnMut(&Self::Item) -> K
25152499
{
2516-
use MinMaxResult::{NoElements, OneElement, MinMax};
2500+
use crate::MinMaxResult::{NoElements, OneElement, MinMax};
25172501
match self.enumerate().minmax_by_key(|e| key(&e.1)) {
25182502
NoElements => NoElements,
25192503
OneElement(x) => OneElement(x.0),
@@ -2556,7 +2540,7 @@ pub trait Itertools : Iterator {
25562540
fn position_minmax_by<F>(self, mut compare: F) -> MinMaxResult<usize>
25572541
where Self: Sized, F: FnMut(&Self::Item, &Self::Item) -> Ordering
25582542
{
2559-
use MinMaxResult::{NoElements, OneElement, MinMax};
2543+
use crate::MinMaxResult::{NoElements, OneElement, MinMax};
25602544
match self.enumerate().minmax_by(|x, y| compare(&x.1, &y.1)) {
25612545
NoElements => NoElements,
25622546
OneElement(x) => OneElement(x.0),

src/merge_join.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::iter::Fuse;
33
use std::fmt;
44

55
use super::adaptors::{PutBack, put_back};
6-
use either_or_both::EitherOrBoth;
6+
use crate::either_or_both::EitherOrBoth;
77

88
/// Return an iterator adaptor that merge-joins items from the two base iterators in ascending order.
99
///

0 commit comments

Comments
 (0)