Stabilize inclusive_range
library feature.
Stabilize std::ops::RangeInclusive and std::ops::RangeInclusiveTo.
This commit is contained in:
parent
5ebf74851d
commit
b5913f2e76
21 changed files with 33 additions and 86 deletions
|
@ -98,7 +98,6 @@
|
|||
#![feature(fundamental)]
|
||||
#![feature(generic_param_attrs)]
|
||||
#![feature(i128_type)]
|
||||
#![feature(inclusive_range)]
|
||||
#![feature(iter_rfold)]
|
||||
#![feature(lang_items)]
|
||||
#![feature(needs_allocator)]
|
||||
|
|
|
@ -103,7 +103,7 @@ impl<T> RangeArgument<T> for Range<T> {
|
|||
}
|
||||
}
|
||||
|
||||
#[unstable(feature = "inclusive_range", reason = "recently added, follows RFC", issue = "28237")]
|
||||
#[stable(feature = "inclusive_range", since = "1.26.0")]
|
||||
impl<T> RangeArgument<T> for RangeInclusive<T> {
|
||||
fn start(&self) -> Bound<&T> {
|
||||
Included(&self.start)
|
||||
|
@ -113,7 +113,7 @@ impl<T> RangeArgument<T> for RangeInclusive<T> {
|
|||
}
|
||||
}
|
||||
|
||||
#[unstable(feature = "inclusive_range", reason = "recently added, follows RFC", issue = "28237")]
|
||||
#[stable(feature = "inclusive_range", since = "1.26.0")]
|
||||
impl<T> RangeArgument<T> for RangeToInclusive<T> {
|
||||
fn start(&self) -> Bound<&T> {
|
||||
Unbounded
|
||||
|
|
|
@ -1876,7 +1876,7 @@ impl ops::Index<ops::RangeFull> for String {
|
|||
unsafe { str::from_utf8_unchecked(&self.vec) }
|
||||
}
|
||||
}
|
||||
#[unstable(feature = "inclusive_range", reason = "recently added, follows RFC", issue = "28237")]
|
||||
#[stable(feature = "inclusive_range", since = "1.26.0")]
|
||||
impl ops::Index<ops::RangeInclusive<usize>> for String {
|
||||
type Output = str;
|
||||
|
||||
|
@ -1885,7 +1885,7 @@ impl ops::Index<ops::RangeInclusive<usize>> for String {
|
|||
Index::index(&**self, index)
|
||||
}
|
||||
}
|
||||
#[unstable(feature = "inclusive_range", reason = "recently added, follows RFC", issue = "28237")]
|
||||
#[stable(feature = "inclusive_range", since = "1.26.0")]
|
||||
impl ops::Index<ops::RangeToInclusive<usize>> for String {
|
||||
type Output = str;
|
||||
|
||||
|
@ -1923,14 +1923,14 @@ impl ops::IndexMut<ops::RangeFull> for String {
|
|||
unsafe { str::from_utf8_unchecked_mut(&mut *self.vec) }
|
||||
}
|
||||
}
|
||||
#[unstable(feature = "inclusive_range", reason = "recently added, follows RFC", issue = "28237")]
|
||||
#[stable(feature = "inclusive_range", since = "1.26.0")]
|
||||
impl ops::IndexMut<ops::RangeInclusive<usize>> for String {
|
||||
#[inline]
|
||||
fn index_mut(&mut self, index: ops::RangeInclusive<usize>) -> &mut str {
|
||||
IndexMut::index_mut(&mut **self, index)
|
||||
}
|
||||
}
|
||||
#[unstable(feature = "inclusive_range", reason = "recently added, follows RFC", issue = "28237")]
|
||||
#[stable(feature = "inclusive_range", since = "1.26.0")]
|
||||
impl ops::IndexMut<ops::RangeToInclusive<usize>> for String {
|
||||
#[inline]
|
||||
fn index_mut(&mut self, index: ops::RangeToInclusive<usize>) -> &mut str {
|
||||
|
|
|
@ -186,9 +186,7 @@ macro_rules! range_exact_iter_impl {
|
|||
|
||||
macro_rules! range_incl_exact_iter_impl {
|
||||
($($t:ty)*) => ($(
|
||||
#[unstable(feature = "inclusive_range",
|
||||
reason = "recently added, follows RFC",
|
||||
issue = "28237")]
|
||||
#[stable(feature = "inclusive_range", since = "1.26.0")]
|
||||
impl ExactSizeIterator for ops::RangeInclusive<$t> { }
|
||||
)*)
|
||||
}
|
||||
|
@ -202,9 +200,7 @@ macro_rules! range_trusted_len_impl {
|
|||
|
||||
macro_rules! range_incl_trusted_len_impl {
|
||||
($($t:ty)*) => ($(
|
||||
#[unstable(feature = "inclusive_range",
|
||||
reason = "recently added, follows RFC",
|
||||
issue = "28237")]
|
||||
#[stable(feature = "inclusive_range", since = "1.26.0")]
|
||||
unsafe impl TrustedLen for ops::RangeInclusive<$t> { }
|
||||
)*)
|
||||
}
|
||||
|
@ -328,7 +324,7 @@ impl<A: Step> FusedIterator for ops::RangeFrom<A> {}
|
|||
#[unstable(feature = "trusted_len", issue = "37572")]
|
||||
unsafe impl<A: Step> TrustedLen for ops::RangeFrom<A> {}
|
||||
|
||||
#[unstable(feature = "inclusive_range", reason = "recently added, follows RFC", issue = "28237")]
|
||||
#[stable(feature = "inclusive_range", since = "1.26.0")]
|
||||
impl<A: Step> Iterator for ops::RangeInclusive<A> {
|
||||
type Item = A;
|
||||
|
||||
|
@ -422,7 +418,7 @@ impl<A: Step> Iterator for ops::RangeInclusive<A> {
|
|||
}
|
||||
}
|
||||
|
||||
#[unstable(feature = "inclusive_range", reason = "recently added, follows RFC", issue = "28237")]
|
||||
#[stable(feature = "inclusive_range", since = "1.26.0")]
|
||||
impl<A: Step> DoubleEndedIterator for ops::RangeInclusive<A> {
|
||||
#[inline]
|
||||
fn next_back(&mut self) -> Option<A> {
|
||||
|
|
|
@ -191,7 +191,7 @@ pub use self::index::{Index, IndexMut};
|
|||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub use self::range::{Range, RangeFrom, RangeFull, RangeTo};
|
||||
|
||||
#[unstable(feature = "inclusive_range", reason = "recently added, follows RFC", issue = "28237")]
|
||||
#[stable(feature = "inclusive_range", since = "1.26.0")]
|
||||
pub use self::range::{RangeInclusive, RangeToInclusive};
|
||||
|
||||
#[unstable(feature = "try_trait", issue = "42327")]
|
||||
|
|
|
@ -283,7 +283,7 @@ impl<Idx: PartialOrd<Idx>> RangeTo<Idx> {
|
|||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// #![feature(inclusive_range,inclusive_range_syntax)]
|
||||
/// #![feature(inclusive_range_syntax)]
|
||||
///
|
||||
/// assert_eq!((3..=5), std::ops::RangeInclusive { start: 3, end: 5 });
|
||||
/// assert_eq!(3 + 4 + 5, (3..=5).sum());
|
||||
|
@ -293,21 +293,17 @@ impl<Idx: PartialOrd<Idx>> RangeTo<Idx> {
|
|||
/// assert_eq!(arr[1..=2], [ 1,2 ]); // RangeInclusive
|
||||
/// ```
|
||||
#[derive(Clone, PartialEq, Eq, Hash)] // not Copy -- see #27186
|
||||
#[unstable(feature = "inclusive_range", reason = "recently added, follows RFC", issue = "28237")]
|
||||
#[stable(feature = "inclusive_range", since = "1.26.0")]
|
||||
pub struct RangeInclusive<Idx> {
|
||||
/// The lower bound of the range (inclusive).
|
||||
#[unstable(feature = "inclusive_range",
|
||||
reason = "recently added, follows RFC",
|
||||
issue = "28237")]
|
||||
#[stable(feature = "inclusive_range", since = "1.26.0")]
|
||||
pub start: Idx,
|
||||
/// The upper bound of the range (inclusive).
|
||||
#[unstable(feature = "inclusive_range",
|
||||
reason = "recently added, follows RFC",
|
||||
issue = "28237")]
|
||||
#[stable(feature = "inclusive_range", since = "1.26.0")]
|
||||
pub end: Idx,
|
||||
}
|
||||
|
||||
#[unstable(feature = "inclusive_range", reason = "recently added, follows RFC", issue = "28237")]
|
||||
#[stable(feature = "inclusive_range", since = "1.26.0")]
|
||||
impl<Idx: fmt::Debug> fmt::Debug for RangeInclusive<Idx> {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(fmt, "{:?}..={:?}", self.start, self.end)
|
||||
|
@ -385,7 +381,7 @@ impl<Idx: PartialOrd<Idx>> RangeInclusive<Idx> {
|
|||
/// The `..=end` syntax is a `RangeToInclusive`:
|
||||
///
|
||||
/// ```
|
||||
/// #![feature(inclusive_range,inclusive_range_syntax)]
|
||||
/// #![feature(inclusive_range_syntax)]
|
||||
/// assert_eq!((..=5), std::ops::RangeToInclusive{ end: 5 });
|
||||
/// ```
|
||||
///
|
||||
|
@ -417,16 +413,14 @@ impl<Idx: PartialOrd<Idx>> RangeInclusive<Idx> {
|
|||
/// [`Iterator`]: ../iter/trait.IntoIterator.html
|
||||
/// [slicing index]: ../slice/trait.SliceIndex.html
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Hash)]
|
||||
#[unstable(feature = "inclusive_range", reason = "recently added, follows RFC", issue = "28237")]
|
||||
#[stable(feature = "inclusive_range", since = "1.26.0")]
|
||||
pub struct RangeToInclusive<Idx> {
|
||||
/// The upper bound of the range (inclusive)
|
||||
#[unstable(feature = "inclusive_range",
|
||||
reason = "recently added, follows RFC",
|
||||
issue = "28237")]
|
||||
#[stable(feature = "inclusive_range", since = "1.26.0")]
|
||||
pub end: Idx,
|
||||
}
|
||||
|
||||
#[unstable(feature = "inclusive_range", reason = "recently added, follows RFC", issue = "28237")]
|
||||
#[stable(feature = "inclusive_range", since = "1.26.0")]
|
||||
impl<Idx: fmt::Debug> fmt::Debug for RangeToInclusive<Idx> {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(fmt, "..={:?}", self.end)
|
||||
|
|
|
@ -1039,7 +1039,7 @@ impl<T> SliceIndex<[T]> for ops::RangeFull {
|
|||
}
|
||||
|
||||
|
||||
#[unstable(feature = "inclusive_range", reason = "recently added, follows RFC", issue = "28237")]
|
||||
#[stable(feature = "inclusive_range", since = "1.26.0")]
|
||||
impl<T> SliceIndex<[T]> for ops::RangeInclusive<usize> {
|
||||
type Output = [T];
|
||||
|
||||
|
@ -1080,7 +1080,7 @@ impl<T> SliceIndex<[T]> for ops::RangeInclusive<usize> {
|
|||
}
|
||||
}
|
||||
|
||||
#[unstable(feature = "inclusive_range", reason = "recently added, follows RFC", issue = "28237")]
|
||||
#[stable(feature = "inclusive_range", since = "1.26.0")]
|
||||
impl<T> SliceIndex<[T]> for ops::RangeToInclusive<usize> {
|
||||
type Output = [T];
|
||||
|
||||
|
|
|
@ -1779,9 +1779,7 @@ mod traits {
|
|||
}
|
||||
}
|
||||
|
||||
#[unstable(feature = "inclusive_range",
|
||||
reason = "recently added, follows RFC",
|
||||
issue = "28237")]
|
||||
#[stable(feature = "inclusive_range", since = "1.26.0")]
|
||||
impl ops::Index<ops::RangeInclusive<usize>> for str {
|
||||
type Output = str;
|
||||
|
||||
|
@ -1791,9 +1789,7 @@ mod traits {
|
|||
}
|
||||
}
|
||||
|
||||
#[unstable(feature = "inclusive_range",
|
||||
reason = "recently added, follows RFC",
|
||||
issue = "28237")]
|
||||
#[stable(feature = "inclusive_range", since = "1.26.0")]
|
||||
impl ops::Index<ops::RangeToInclusive<usize>> for str {
|
||||
type Output = str;
|
||||
|
||||
|
@ -1803,18 +1799,14 @@ mod traits {
|
|||
}
|
||||
}
|
||||
|
||||
#[unstable(feature = "inclusive_range",
|
||||
reason = "recently added, follows RFC",
|
||||
issue = "28237")]
|
||||
#[stable(feature = "inclusive_range", since = "1.26.0")]
|
||||
impl ops::IndexMut<ops::RangeInclusive<usize>> for str {
|
||||
#[inline]
|
||||
fn index_mut(&mut self, index: ops::RangeInclusive<usize>) -> &mut str {
|
||||
index.index_mut(self)
|
||||
}
|
||||
}
|
||||
#[unstable(feature = "inclusive_range",
|
||||
reason = "recently added, follows RFC",
|
||||
issue = "28237")]
|
||||
#[stable(feature = "inclusive_range", since = "1.26.0")]
|
||||
impl ops::IndexMut<ops::RangeToInclusive<usize>> for str {
|
||||
#[inline]
|
||||
fn index_mut(&mut self, index: ops::RangeToInclusive<usize>) -> &mut str {
|
||||
|
@ -1997,9 +1989,7 @@ mod traits {
|
|||
}
|
||||
}
|
||||
|
||||
#[unstable(feature = "inclusive_range",
|
||||
reason = "recently added, follows RFC",
|
||||
issue = "28237")]
|
||||
#[stable(feature = "inclusive_range", since = "1.26.0")]
|
||||
impl SliceIndex<str> for ops::RangeInclusive<usize> {
|
||||
type Output = str;
|
||||
#[inline]
|
||||
|
@ -2042,9 +2032,7 @@ mod traits {
|
|||
|
||||
|
||||
|
||||
#[unstable(feature = "inclusive_range",
|
||||
reason = "recently added, follows RFC",
|
||||
issue = "28237")]
|
||||
#[stable(feature = "inclusive_range", since = "1.26.0")]
|
||||
impl SliceIndex<str> for ops::RangeToInclusive<usize> {
|
||||
type Output = str;
|
||||
#[inline]
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
#![feature(fmt_internals)]
|
||||
#![feature(iterator_step_by)]
|
||||
#![feature(i128_type)]
|
||||
#![feature(inclusive_range)]
|
||||
#![feature(inclusive_range_syntax)]
|
||||
#![feature(iterator_try_fold)]
|
||||
#![feature(iterator_flatten)]
|
||||
|
|
|
@ -54,7 +54,6 @@
|
|||
#![feature(fs_read_write)]
|
||||
#![feature(i128)]
|
||||
#![feature(i128_type)]
|
||||
#![feature(inclusive_range)]
|
||||
#![feature(inclusive_range_syntax)]
|
||||
#![cfg_attr(windows, feature(libc))]
|
||||
#![feature(match_default_bindings)]
|
||||
|
|
|
@ -29,7 +29,6 @@ Rust MIR: a lowered representation of Rust. Also: an experiment!
|
|||
#![feature(fs_read_write)]
|
||||
#![feature(i128_type)]
|
||||
#![feature(inclusive_range_syntax)]
|
||||
#![feature(inclusive_range)]
|
||||
#![feature(macro_vis_matcher)]
|
||||
#![feature(match_default_bindings)]
|
||||
#![feature(exhaustive_patterns)]
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
#![allow(unused_attributes)]
|
||||
#![feature(i128_type)]
|
||||
#![feature(i128)]
|
||||
#![feature(inclusive_range)]
|
||||
#![feature(inclusive_range_syntax)]
|
||||
#![feature(libc)]
|
||||
#![feature(quote)]
|
||||
|
|
|
@ -271,7 +271,6 @@
|
|||
#![feature(heap_api)]
|
||||
#![feature(i128)]
|
||||
#![feature(i128_type)]
|
||||
#![feature(inclusive_range)]
|
||||
#![feature(int_error_internals)]
|
||||
#![feature(integer_atomics)]
|
||||
#![feature(into_cow)]
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// Make sure that #![feature(inclusive_range)] is required.
|
||||
|
||||
#![feature(inclusive_range_syntax)]
|
||||
// #![feature(inclusive_range)]
|
||||
|
||||
pub fn main() {
|
||||
let _: std::ops::RangeInclusive<_> = { use std::intrinsics; 1 } ..= { use std::intrinsics; 2 };
|
||||
//~^ ERROR use of unstable library feature 'inclusive_range'
|
||||
//~| ERROR core_intrinsics
|
||||
//~| ERROR core_intrinsics
|
||||
}
|
|
@ -8,8 +8,6 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![feature(inclusive_range)]
|
||||
|
||||
use std::ops::*;
|
||||
|
||||
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![feature(inclusive_range)]
|
||||
|
||||
use std::ops::*;
|
||||
|
||||
#[derive(Copy, Clone)] //~ ERROR Copy
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![feature(rustc_attrs, inclusive_range)]
|
||||
#![feature(rustc_attrs)]
|
||||
|
||||
use std::ops::*;
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
// Make sure that inclusive ranges with no end point don't parse.
|
||||
|
||||
#![feature(inclusive_range_syntax, inclusive_range)]
|
||||
#![feature(inclusive_range_syntax)]
|
||||
|
||||
pub fn main() {
|
||||
for _ in 1..= {} //~ERROR inclusive range with no end
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
// Make sure that inclusive ranges with `...` syntax don't parse.
|
||||
|
||||
#![feature(inclusive_range_syntax, inclusive_range)]
|
||||
#![feature(inclusive_range_syntax)]
|
||||
|
||||
use std::ops::RangeToInclusive;
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
// Make sure that #![feature(inclusive_range_syntax)] is required.
|
||||
|
||||
// #![feature(inclusive_range_syntax, inclusive_range)]
|
||||
// #![feature(inclusive_range_syntax)]
|
||||
|
||||
macro_rules! m {
|
||||
() => { for _ in 1..=10 {} } //~ ERROR inclusive range syntax is experimental
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
// Test inclusive range syntax.
|
||||
|
||||
#![feature(inclusive_range_syntax, inclusive_range, iterator_step_by)]
|
||||
#![feature(inclusive_range_syntax, iterator_step_by)]
|
||||
|
||||
use std::ops::{RangeInclusive, RangeToInclusive};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue