Skip to content

Commit edded89

Browse files
committed
---
yaml --- r: 190326 b: refs/heads/tmp c: 0b01a9b h: refs/heads/master v: v3
1 parent 0432da0 commit edded89

File tree

21 files changed

+138
-175
lines changed

21 files changed

+138
-175
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,6 @@ refs/heads/building: 126db549b038c84269a1e4fe46f051b2c15d6970
3434
refs/heads/beta: 522d09dfecbeca1595f25ac58c6d0178bbd21d7d
3535
refs/heads/windistfix: 7608dbad651f02e837ed05eef3d74a6662a6e928
3636
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
37-
refs/heads/tmp: 7a306b1b005eb7c870f7ebad75f6d19b6e995236
37+
refs/heads/tmp: 0b01a9bb4b93e3f763b4ab924179462b415991d4
3838
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f
3939
refs/tags/homu-tmp: 4a5101a42f8ea36bdbe14749e672ab78cb971726

branches/tmp/src/libcollections/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
#![feature(unsafe_destructor)]
3434
#![feature(unique)]
3535
#![feature(unsafe_no_drop_flag)]
36-
#![feature(step_by)]
3736
#![cfg_attr(test, feature(rand, rustc_private, test))]
3837
#![cfg_attr(test, allow(deprecated))] // rand
3938

branches/tmp/src/libcollections/slice.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ use core::clone::Clone;
9292
use core::cmp::Ordering::{self, Greater, Less};
9393
use core::cmp::{self, Ord, PartialEq};
9494
use core::iter::{Iterator, IteratorExt};
95-
use core::iter::MultiplicativeIterator;
95+
use core::iter::{range_step, MultiplicativeIterator};
9696
use core::marker::Sized;
9797
use core::mem::size_of;
9898
use core::mem;
@@ -1387,7 +1387,7 @@ fn merge_sort<T, F>(v: &mut [T], mut compare: F) where F: FnMut(&T, &T) -> Order
13871387
// We could hardcode the sorting comparisons here, and we could
13881388
// manipulate/step the pointers themselves, rather than repeatedly
13891389
// .offset-ing.
1390-
for start in (0.. len).step_by(insertion) {
1390+
for start in range_step(0, len, insertion) {
13911391
// start <= i < len;
13921392
for i in start..cmp::min(start + insertion, len) {
13931393
// j satisfies: start <= j <= i;
@@ -1427,7 +1427,7 @@ fn merge_sort<T, F>(v: &mut [T], mut compare: F) where F: FnMut(&T, &T) -> Order
14271427
// a time, placing the result in `buf_tmp`.
14281428

14291429
// 0 <= start <= len.
1430-
for start in (0..len).step_by(2 * width) {
1430+
for start in range_step(0, len, 2 * width) {
14311431
// manipulate pointers directly for speed (rather than
14321432
// using a `for` loop with `range` and `.offset` inside
14331433
// that loop).

branches/tmp/src/libcore/iter.rs

Lines changed: 69 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ use default::Default;
6565
use marker;
6666
use mem;
6767
use num::{ToPrimitive, Int};
68-
use ops::{Add, Deref, FnMut, RangeFrom};
68+
use ops::{Add, Deref, FnMut};
6969
use option::Option;
7070
use option::Option::{Some, None};
7171
use marker::Sized;
@@ -2366,101 +2366,34 @@ impl<A, St, F> Iterator for Unfold<St, F> where F: FnMut(&mut St) -> Option<A> {
23662366
}
23672367
}
23682368

2369-
/// An adapter for stepping range iterators by a custom amount.
2370-
///
2371-
/// The resulting iterator handles overflow by stopping. The `A`
2372-
/// parameter is the type being iterated over, while `R` is the range
2373-
/// type (usually one of `std::ops::{Range, RangeFrom}`.
2374-
#[derive(Clone)]
2375-
#[unstable(feature = "step_by", reason = "recent addition")]
2376-
pub struct StepBy<A, R> {
2377-
step_by: A,
2378-
range: R,
2379-
}
2380-
2381-
impl<A: Add> RangeFrom<A> {
2382-
/// Creates an iterator starting at the same point, but stepping by
2383-
/// the given amount at each iteration.
2384-
///
2385-
/// # Examples
2386-
///
2387-
/// ```ignore
2388-
/// for i in (0u8..).step_by(2) {
2389-
/// println!("{}", i);
2390-
/// }
2391-
/// ```
2392-
///
2393-
/// This prints all even `u8` values.
2394-
#[unstable(feature = "step_by", reason = "recent addition")]
2395-
pub fn step_by(self, by: A) -> StepBy<A, Self> {
2396-
StepBy {
2397-
step_by: by,
2398-
range: self
2399-
}
2400-
}
2401-
}
2402-
2403-
impl<A: Int> ::ops::Range<A> {
2404-
/// Creates an iterator with the same range, but stepping by the
2405-
/// given amount at each iteration.
2406-
///
2407-
/// The resulting iterator handles overflow by stopping.
2408-
///
2409-
/// # Examples
2410-
///
2411-
/// ```
2412-
/// # #![feature(step_by, core)]
2413-
/// for i in (0..10).step_by(2) {
2414-
/// println!("{}", i);
2415-
/// }
2416-
/// ```
2417-
///
2418-
/// This prints:
2419-
///
2420-
/// ```text
2421-
/// 0
2422-
/// 2
2423-
/// 4
2424-
/// 6
2425-
/// 8
2426-
/// ```
2427-
#[unstable(feature = "step_by", reason = "recent addition")]
2428-
pub fn step_by(self, by: A) -> StepBy<A, Self> {
2429-
StepBy {
2430-
step_by: by,
2431-
range: self
2432-
}
2433-
}
2434-
}
2435-
24362369
/// An infinite iterator starting at `start` and advancing by `step` with each
24372370
/// iteration
2371+
#[derive(Clone)]
24382372
#[unstable(feature = "core",
24392373
reason = "may be renamed or replaced by range notation adapters")]
2440-
#[deprecated(since = "1.0.0-beta", reason = "use range notation and step_by")]
2441-
pub type Counter<A> = StepBy<A, RangeFrom<A>>;
2374+
pub struct Counter<A> {
2375+
/// The current state the counter is at (next value to be yielded)
2376+
state: A,
2377+
/// The amount that this iterator is stepping by
2378+
step: A,
2379+
}
24422380

2443-
/// Deprecated: use `(start..).step_by(step)` instead.
2381+
/// Creates a new counter with the specified start/step
24442382
#[inline]
24452383
#[unstable(feature = "core",
24462384
reason = "may be renamed or replaced by range notation adapters")]
2447-
#[deprecated(since = "1.0.0-beta", reason = "use (start..).step_by(step) instead")]
2448-
#[allow(deprecated)]
24492385
pub fn count<A>(start: A, step: A) -> Counter<A> {
2450-
StepBy {
2451-
range: RangeFrom { start: start },
2452-
step_by: step,
2453-
}
2386+
Counter{state: start, step: step}
24542387
}
24552388

24562389
#[stable(feature = "rust1", since = "1.0.0")]
2457-
impl<A: Add<Output=A> + Clone> Iterator for StepBy<A, RangeFrom<A>> {
2390+
impl<A: Add<Output=A> + Clone> Iterator for Counter<A> {
24582391
type Item = A;
24592392

24602393
#[inline]
24612394
fn next(&mut self) -> Option<A> {
2462-
let result = self.range.start.clone();
2463-
self.range.start = result.clone() + self.step_by.clone();
2395+
let result = self.state.clone();
2396+
self.state = self.state.clone() + self.step.clone();
24642397
Some(result)
24652398
}
24662399

@@ -2471,22 +2404,31 @@ impl<A: Add<Output=A> + Clone> Iterator for StepBy<A, RangeFrom<A>> {
24712404
}
24722405

24732406
/// An iterator over the range [start, stop)
2474-
#[allow(deprecated)]
24752407
#[derive(Clone)]
24762408
#[unstable(feature = "core",
24772409
reason = "will be replaced by range notation")]
2478-
#[deprecated(since = "1.0.0-beta", reason = "use range notation")]
24792410
pub struct Range<A> {
24802411
state: A,
24812412
stop: A,
24822413
one: A,
24832414
}
24842415

2485-
/// Deprecated: use `(start..stop)` instead.
2416+
/// Returns an iterator over the given range [start, stop) (that is, starting
2417+
/// at start (inclusive), and ending at stop (exclusive)).
2418+
///
2419+
/// # Examples
2420+
///
2421+
/// ```
2422+
/// let array = [0, 1, 2, 3, 4];
2423+
///
2424+
/// for i in range(0, 5) {
2425+
/// println!("{}", i);
2426+
/// assert_eq!(i, array[i]);
2427+
/// }
2428+
/// ```
24862429
#[inline]
2487-
#[unstable(feature = "core", reason = "will be replaced by range notation")]
2488-
#[deprecated(since = "1.0.0-beta", reason = "use (start..stop) instead")]
2489-
#[allow(deprecated)]
2430+
#[unstable(feature = "core",
2431+
reason = "will be replaced by range notation")]
24902432
pub fn range<A: Int>(start: A, stop: A) -> Range<A> {
24912433
Range {
24922434
state: start,
@@ -2498,8 +2440,6 @@ pub fn range<A: Int>(start: A, stop: A) -> Range<A> {
24982440
// FIXME: #10414: Unfortunate type bound
24992441
#[unstable(feature = "core",
25002442
reason = "will be replaced by range notation")]
2501-
#[deprecated(since = "1.0.0-beta", reason = "use range notation")]
2502-
#[allow(deprecated)]
25032443
impl<A: Int + ToPrimitive> Iterator for Range<A> {
25042444
type Item = A;
25052445

@@ -2551,8 +2491,6 @@ impl<A: Int + ToPrimitive> Iterator for Range<A> {
25512491
/// the direction it is consumed.
25522492
#[unstable(feature = "core",
25532493
reason = "will be replaced by range notation")]
2554-
#[deprecated(since = "1.0.0-beta", reason = "use range notation")]
2555-
#[allow(deprecated)]
25562494
impl<A: Int + ToPrimitive> DoubleEndedIterator for Range<A> {
25572495
#[inline]
25582496
fn next_back(&mut self) -> Option<A> {
@@ -2569,7 +2507,6 @@ impl<A: Int + ToPrimitive> DoubleEndedIterator for Range<A> {
25692507
#[derive(Clone)]
25702508
#[unstable(feature = "core",
25712509
reason = "likely to be replaced by range notation and adapters")]
2572-
#[allow(deprecated)]
25732510
pub struct RangeInclusive<A> {
25742511
range: Range<A>,
25752512
done: bool,
@@ -2579,7 +2516,6 @@ pub struct RangeInclusive<A> {
25792516
#[inline]
25802517
#[unstable(feature = "core",
25812518
reason = "likely to be replaced by range notation and adapters")]
2582-
#[allow(deprecated)]
25832519
pub fn range_inclusive<A: Int>(start: A, stop: A) -> RangeInclusive<A> {
25842520
RangeInclusive {
25852521
range: range(start, stop),
@@ -2589,7 +2525,6 @@ pub fn range_inclusive<A: Int>(start: A, stop: A) -> RangeInclusive<A> {
25892525

25902526
#[unstable(feature = "core",
25912527
reason = "likely to be replaced by range notation and adapters")]
2592-
#[allow(deprecated)]
25932528
impl<A: Int + ToPrimitive> Iterator for RangeInclusive<A> {
25942529
type Item = A;
25952530

@@ -2626,7 +2561,6 @@ impl<A: Int + ToPrimitive> Iterator for RangeInclusive<A> {
26262561

26272562
#[unstable(feature = "core",
26282563
reason = "likely to be replaced by range notation and adapters")]
2629-
#[allow(deprecated)]
26302564
impl<A: Int + ToPrimitive> DoubleEndedIterator for RangeInclusive<A> {
26312565
#[inline]
26322566
fn next_back(&mut self) -> Option<A> {
@@ -2644,39 +2578,61 @@ impl<A: Int + ToPrimitive> DoubleEndedIterator for RangeInclusive<A> {
26442578
}
26452579

26462580
/// An iterator over the range [start, stop) by `step`. It handles overflow by stopping.
2581+
#[derive(Clone)]
26472582
#[unstable(feature = "core",
26482583
reason = "likely to be replaced by range notation and adapters")]
2649-
#[deprecated(since = "1.0.0-beta", reason = "use range notation and step_by")]
2650-
pub type RangeStep<A> = StepBy<A, ::ops::Range<A>>;
2584+
pub struct RangeStep<A> {
2585+
state: A,
2586+
stop: A,
2587+
step: A,
2588+
rev: bool,
2589+
}
26512590

2652-
/// Deprecated: use `(start..stop).step_by(step)` instead.
2591+
/// Return an iterator over the range [start, stop) by `step`.
2592+
///
2593+
/// It handles overflow by stopping.
2594+
///
2595+
/// # Examples
2596+
///
2597+
/// ```
2598+
/// use std::iter::range_step;
2599+
///
2600+
/// for i in range_step(0, 10, 2) {
2601+
/// println!("{}", i);
2602+
/// }
2603+
/// ```
2604+
///
2605+
/// This prints:
2606+
///
2607+
/// ```text
2608+
/// 0
2609+
/// 2
2610+
/// 4
2611+
/// 6
2612+
/// 8
2613+
/// ```
26532614
#[inline]
26542615
#[unstable(feature = "core",
26552616
reason = "likely to be replaced by range notation and adapters")]
2656-
#[deprecated(since = "1.0.0-beta",
2657-
reason = "use `(start..stop).step_by(step)` instead")]
2658-
#[allow(deprecated)]
26592617
pub fn range_step<A: Int>(start: A, stop: A, step: A) -> RangeStep<A> {
2660-
StepBy {
2661-
step_by: step,
2662-
range: ::ops::Range { start: start, end: stop },
2663-
}
2618+
let rev = step < Int::zero();
2619+
RangeStep{state: start, stop: stop, step: step, rev: rev}
26642620
}
26652621

2666-
#[stable(feature = "rust1", since = "1.0.0")]
2667-
impl<A: Int> Iterator for StepBy<A, ::ops::Range<A>> {
2622+
#[unstable(feature = "core",
2623+
reason = "likely to be replaced by range notation and adapters")]
2624+
impl<A: Int> Iterator for RangeStep<A> {
26682625
type Item = A;
26692626

26702627
#[inline]
26712628
fn next(&mut self) -> Option<A> {
2672-
let rev = self.step_by < Int::zero();
2673-
let start = self.range.start;
2674-
if (rev && start > self.range.end) || (!rev && start < self.range.end) {
2675-
match start.checked_add(self.step_by) {
2676-
Some(x) => self.range.start = x,
2677-
None => self.range.start = self.range.end.clone()
2629+
if (self.rev && self.state > self.stop) || (!self.rev && self.state < self.stop) {
2630+
let result = self.state;
2631+
match self.state.checked_add(self.step) {
2632+
Some(x) => self.state = x,
2633+
None => self.state = self.stop.clone()
26782634
}
2679-
Some(start)
2635+
Some(result)
26802636
} else {
26812637
None
26822638
}

branches/tmp/src/libcore/prelude.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ pub use marker::{Copy, Send, Sized, Sync};
2929
pub use ops::{Drop, Fn, FnMut, FnOnce};
3030

3131
// Reexported functions
32-
#[allow(deprecated)]
3332
pub use iter::range;
3433
pub use mem::drop;
3534

branches/tmp/src/libcoretest/iter.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -775,12 +775,12 @@ fn test_range_inclusive() {
775775

776776
#[test]
777777
fn test_range_step() {
778-
assert_eq!((0..20).step_by(5).collect::<Vec<int>>(), [0, 5, 10, 15]);
779-
assert_eq!((20..0).step_by(-5).collect::<Vec<int>>(), [20, 15, 10, 5]);
780-
assert_eq!((20..0).step_by(-6).collect::<Vec<int>>(), [20, 14, 8, 2]);
781-
assert_eq!((200..255).step_by(50).collect::<Vec<u8>>(), [200, 250]);
782-
assert_eq!((200..-5).step_by(1).collect::<Vec<int>>(), []);
783-
assert_eq!((200..200).step_by(1).collect::<Vec<int>>(), []);
778+
assert_eq!(range_step(0, 20, 5).collect::<Vec<int>>(), [0, 5, 10, 15]);
779+
assert_eq!(range_step(20, 0, -5).collect::<Vec<int>>(), [20, 15, 10, 5]);
780+
assert_eq!(range_step(20, 0, -6).collect::<Vec<int>>(), [20, 14, 8, 2]);
781+
assert_eq!(range_step(200, 255, 50).collect::<Vec<u8>>(), [200, 250]);
782+
assert_eq!(range_step(200, -5, 1).collect::<Vec<int>>(), []);
783+
assert_eq!(range_step(200, 200, 1).collect::<Vec<int>>(), []);
784784
}
785785

786786
#[test]

branches/tmp/src/librand/distributions/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
//! internally. The `IndependentSample` trait is for generating values
1818
//! that do not need to record state.
1919
20+
#![unstable(feature = "rand")]
21+
2022
use core::prelude::*;
2123
use core::num::{Float, Int};
2224
use core::marker::PhantomData;

branches/tmp/src/librustc/middle/infer/combine.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ pub trait Combine<'tcx> : Sized {
154154
b_tys.len())));
155155
}
156156

157-
(0.. a_tys.len()).map(|i| {
157+
range(0, a_tys.len()).map(|i| {
158158
let a_ty = a_tys[i];
159159
let b_ty = b_tys[i];
160160
let v = variances.map_or(ty::Invariant, |v| v[i]);

branches/tmp/src/librustc_back/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848
#![feature(path_ext)]
4949
#![feature(std_misc)]
5050
#![feature(path_relative_from)]
51-
#![feature(step_by)]
5251

5352
extern crate syntax;
5453
extern crate serialize;

0 commit comments

Comments
 (0)