Skip to content

Commit e157fa3

Browse files
committed
move RangeArgument to ops
1 parent ba356ff commit e157fa3

File tree

6 files changed

+68
-70
lines changed

6 files changed

+68
-70
lines changed

src/libcollections/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#![feature(alloc)]
3333
#![feature(box_patterns)]
3434
#![feature(box_syntax)]
35+
#![feature(collections_range)]
3536
#![feature(core_intrinsics)]
3637
#![feature(decode_utf16)]
3738
#![feature(drop_in_place)]
@@ -89,7 +90,6 @@ pub mod borrow;
8990
pub mod enum_set;
9091
pub mod fmt;
9192
pub mod linked_list;
92-
pub mod range;
9393
pub mod slice;
9494
pub mod str;
9595
pub mod string;

src/libcollections/range.rs

Lines changed: 0 additions & 60 deletions
This file was deleted.

src/libcollections/string.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ use core::fmt;
5959
use core::hash;
6060
use core::iter::FromIterator;
6161
use core::mem;
62-
use core::ops::{self, Add};
62+
use core::ops::{self, Add, RangeArgument};
6363
use core::ptr;
6464
use core::slice;
6565
use core::str::pattern::Pattern;
@@ -68,7 +68,6 @@ use rustc_unicode::str as unicode_str;
6868

6969
#[allow(deprecated)]
7070
use borrow::{Cow, IntoCow};
71-
use range::RangeArgument;
7271
use str::{self, FromStr, Utf8Error, Chars};
7372
use vec::Vec;
7473
use boxed::Box;

src/libcollections/vec.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,16 +68,14 @@ use core::hash::{self, Hash};
6868
use core::intrinsics::{arith_offset, assume, needs_drop};
6969
use core::iter::FromIterator;
7070
use core::mem;
71-
use core::ops::{Index, IndexMut};
71+
use core::ops::{Index, IndexMut, RangeArgument};
7272
use core::ops;
7373
use core::ptr;
7474
use core::slice;
7575

7676
#[allow(deprecated)]
7777
use borrow::{Cow, IntoCow};
7878

79-
use super::range::RangeArgument;
80-
8179
/// A growable list type, written `Vec<T>` but pronounced 'vector.'
8280
///
8381
/// # Examples

src/libcollections/vec_deque.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use core::cmp::Ordering;
2222
use core::fmt;
2323
use core::iter::{repeat, FromIterator};
2424
use core::mem;
25-
use core::ops::{Index, IndexMut};
25+
use core::ops::{Index, IndexMut, RangeArgument};
2626
use core::ptr;
2727
use core::slice;
2828

@@ -31,8 +31,6 @@ use core::cmp;
3131

3232
use alloc::raw_vec::RawVec;
3333

34-
use super::range::RangeArgument;
35-
3634
const INITIAL_CAPACITY: usize = 7; // 2^3 - 1
3735
const MINIMUM_CAPACITY: usize = 1; // 2 - 1
3836
#[cfg(target_pointer_width = "32")]

src/libcore/ops.rs

Lines changed: 64 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,10 @@
6767
6868
#![stable(feature = "rust1", since = "1.0.0")]
6969

70-
use marker::{Sized, Unsize};
7170
use fmt;
71+
use marker::{Sized, Unsize};
72+
use option::Option;
73+
use option::Option::{Some, None};
7274

7375
/// The `Drop` trait is used to run some code when a value goes out of scope.
7476
/// This is sometimes called a 'destructor'.
@@ -1885,3 +1887,64 @@ pub trait BoxPlace<Data: ?Sized> : Place<Data> {
18851887
/// Creates a globally fresh place.
18861888
fn make_place() -> Self;
18871889
}
1890+
1891+
1892+
1893+
1894+
/// **RangeArgument** is implemented by Rust's built-in range types, produced
1895+
/// by range syntax like `..`, `a..`, `..b` or `c..d`.
1896+
#[unstable(feature = "collections_range",
1897+
reason = "waiting for dust to settle on inclusive ranges",
1898+
issue = "30877")]
1899+
pub trait RangeArgument<T> {
1900+
/// Start index (inclusive)
1901+
///
1902+
/// Return start value if present, else `None`.
1903+
fn start(&self) -> Option<&T> {
1904+
None
1905+
}
1906+
1907+
/// End index (exclusive)
1908+
///
1909+
/// Return end value if present, else `None`.
1910+
fn end(&self) -> Option<&T> {
1911+
None
1912+
}
1913+
}
1914+
1915+
1916+
#[unstable(feature = "collections_range",
1917+
reason = "waiting for dust to settle on inclusive ranges",
1918+
issue = "30877")]
1919+
impl<T> RangeArgument<T> for RangeFull {}
1920+
1921+
#[unstable(feature = "collections_range",
1922+
reason = "waiting for dust to settle on inclusive ranges",
1923+
issue = "30877")]
1924+
impl<T> RangeArgument<T> for RangeFrom<T> {
1925+
fn start(&self) -> Option<&T> {
1926+
Some(&self.start)
1927+
}
1928+
}
1929+
1930+
#[unstable(feature = "collections_range",
1931+
reason = "waiting for dust to settle on inclusive ranges",
1932+
issue = "30877")]
1933+
impl<T> RangeArgument<T> for RangeTo<T> {
1934+
fn end(&self) -> Option<&T> {
1935+
Some(&self.end)
1936+
}
1937+
}
1938+
1939+
#[unstable(feature = "collections_range",
1940+
reason = "waiting for dust to settle on inclusive ranges",
1941+
issue = "30877")]
1942+
impl<T> RangeArgument<T> for Range<T> {
1943+
fn start(&self) -> Option<&T> {
1944+
Some(&self.start)
1945+
}
1946+
fn end(&self) -> Option<&T> {
1947+
Some(&self.end)
1948+
}
1949+
}
1950+

0 commit comments

Comments
 (0)