Skip to content

Commit 46de2af

Browse files
committed
std: Stabilize str_checked_slicing feature
Stabilized * `<str>::get` * `<str>::get_mut` * `<str>::get_unchecked` * `<str>::get_unchecked_mut` Closes #39932
1 parent 64c1b23 commit 46de2af

File tree

4 files changed

+14
-20
lines changed

4 files changed

+14
-20
lines changed

src/liballoc/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@
8282
#![cfg_attr(not(test), feature(core_float))]
8383
#![cfg_attr(not(test), feature(exact_size_is_empty))]
8484
#![cfg_attr(not(test), feature(slice_rotate))]
85-
#![cfg_attr(not(test), feature(str_checked_slicing))]
8685
#![cfg_attr(test, feature(rand, test))]
8786
#![cfg_attr(stage0, feature(allocator))]
8887
#![feature(allow_internal_unstable)]

src/liballoc/str.rs

+4-8
Original file line numberDiff line numberDiff line change
@@ -328,14 +328,13 @@ impl str {
328328
/// # Examples
329329
///
330330
/// ```
331-
/// # #![feature(str_checked_slicing)]
332331
/// let v = "🗻∈🌏";
333332
/// assert_eq!(Some("🗻"), v.get(0..4));
334333
/// assert!(v.get(1..).is_none());
335334
/// assert!(v.get(..8).is_none());
336335
/// assert!(v.get(..42).is_none());
337336
/// ```
338-
#[unstable(feature = "str_checked_slicing", issue = "39932")]
337+
#[stable(feature = "str_checked_slicing", since = "1.20.0")]
339338
#[inline]
340339
pub fn get<I: SliceIndex<str>>(&self, i: I) -> Option<&I::Output> {
341340
core_str::StrExt::get(self, i)
@@ -351,14 +350,13 @@ impl str {
351350
/// # Examples
352351
///
353352
/// ```
354-
/// # #![feature(str_checked_slicing)]
355353
/// let mut v = String::from("🗻∈🌏");
356354
/// assert_eq!(Some("🗻"), v.get_mut(0..4).map(|v| &*v));
357355
/// assert!(v.get_mut(1..).is_none());
358356
/// assert!(v.get_mut(..8).is_none());
359357
/// assert!(v.get_mut(..42).is_none());
360358
/// ```
361-
#[unstable(feature = "str_checked_slicing", issue = "39932")]
359+
#[stable(feature = "str_checked_slicing", since = "1.20.0")]
362360
#[inline]
363361
pub fn get_mut<I: SliceIndex<str>>(&mut self, i: I) -> Option<&mut I::Output> {
364362
core_str::StrExt::get_mut(self, i)
@@ -383,15 +381,14 @@ impl str {
383381
/// # Examples
384382
///
385383
/// ```
386-
/// # #![feature(str_checked_slicing)]
387384
/// let v = "🗻∈🌏";
388385
/// unsafe {
389386
/// assert_eq!("🗻", v.get_unchecked(0..4));
390387
/// assert_eq!("∈", v.get_unchecked(4..7));
391388
/// assert_eq!("🌏", v.get_unchecked(7..11));
392389
/// }
393390
/// ```
394-
#[unstable(feature = "str_checked_slicing", issue = "39932")]
391+
#[stable(feature = "str_checked_slicing", since = "1.20.0")]
395392
#[inline]
396393
pub unsafe fn get_unchecked<I: SliceIndex<str>>(&self, i: I) -> &I::Output {
397394
core_str::StrExt::get_unchecked(self, i)
@@ -416,15 +413,14 @@ impl str {
416413
/// # Examples
417414
///
418415
/// ```
419-
/// # #![feature(str_checked_slicing)]
420416
/// let mut v = String::from("🗻∈🌏");
421417
/// unsafe {
422418
/// assert_eq!("🗻", v.get_unchecked_mut(0..4));
423419
/// assert_eq!("∈", v.get_unchecked_mut(4..7));
424420
/// assert_eq!("🌏", v.get_unchecked_mut(7..11));
425421
/// }
426422
/// ```
427-
#[unstable(feature = "str_checked_slicing", issue = "39932")]
423+
#[stable(feature = "str_checked_slicing", since = "1.20.0")]
428424
#[inline]
429425
pub unsafe fn get_unchecked_mut<I: SliceIndex<str>>(&mut self, i: I) -> &mut I::Output {
430426
core_str::StrExt::get_unchecked_mut(self, i)

src/liballoc/tests/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
#![feature(repr_align)]
2525
#![feature(slice_rotate)]
2626
#![feature(splice)]
27-
#![feature(str_checked_slicing)]
2827
#![feature(str_escape)]
2928
#![feature(test)]
3029
#![feature(unboxed_closures)]

src/libcore/str/mod.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -1776,7 +1776,7 @@ mod traits {
17761776
}
17771777
}
17781778

1779-
#[unstable(feature = "str_checked_slicing", issue = "39932")]
1779+
#[stable(feature = "str_checked_slicing", since = "1.20.0")]
17801780
impl SliceIndex<str> for ops::RangeFull {
17811781
type Output = str;
17821782
#[inline]
@@ -1805,7 +1805,7 @@ mod traits {
18051805
}
18061806
}
18071807

1808-
#[unstable(feature = "str_checked_slicing", issue = "39932")]
1808+
#[stable(feature = "str_checked_slicing", since = "1.20.0")]
18091809
impl SliceIndex<str> for ops::Range<usize> {
18101810
type Output = str;
18111811
#[inline]
@@ -1859,7 +1859,7 @@ mod traits {
18591859
}
18601860
}
18611861

1862-
#[unstable(feature = "str_checked_slicing", issue = "39932")]
1862+
#[stable(feature = "str_checked_slicing", since = "1.20.0")]
18631863
impl SliceIndex<str> for ops::RangeTo<usize> {
18641864
type Output = str;
18651865
#[inline]
@@ -1904,7 +1904,7 @@ mod traits {
19041904
}
19051905
}
19061906

1907-
#[unstable(feature = "str_checked_slicing", issue = "39932")]
1907+
#[stable(feature = "str_checked_slicing", since = "1.20.0")]
19081908
impl SliceIndex<str> for ops::RangeFrom<usize> {
19091909
type Output = str;
19101910
#[inline]
@@ -1951,7 +1951,7 @@ mod traits {
19511951
}
19521952
}
19531953

1954-
#[unstable(feature = "str_checked_slicing", issue = "39932")]
1954+
#[stable(feature = "str_checked_slicing", since = "1.20.0")]
19551955
impl SliceIndex<str> for ops::RangeInclusive<usize> {
19561956
type Output = str;
19571957
#[inline]
@@ -1994,7 +1994,7 @@ mod traits {
19941994

19951995

19961996

1997-
#[unstable(feature = "str_checked_slicing", issue = "39932")]
1997+
#[stable(feature = "str_checked_slicing", since = "1.20.0")]
19981998
impl SliceIndex<str> for ops::RangeToInclusive<usize> {
19991999
type Output = str;
20002000
#[inline]
@@ -2094,13 +2094,13 @@ pub trait StrExt {
20942094
#[rustc_deprecated(since = "1.6.0", reason = "use lines() instead now")]
20952095
#[allow(deprecated)]
20962096
fn lines_any(&self) -> LinesAny;
2097-
#[unstable(feature = "str_checked_slicing", issue = "39932")]
2097+
#[stable(feature = "str_checked_slicing", since = "1.20.0")]
20982098
fn get<I: SliceIndex<str>>(&self, i: I) -> Option<&I::Output>;
2099-
#[unstable(feature = "str_checked_slicing", issue = "39932")]
2099+
#[stable(feature = "str_checked_slicing", since = "1.20.0")]
21002100
fn get_mut<I: SliceIndex<str>>(&mut self, i: I) -> Option<&mut I::Output>;
2101-
#[unstable(feature = "str_checked_slicing", issue = "39932")]
2101+
#[stable(feature = "str_checked_slicing", since = "1.20.0")]
21022102
unsafe fn get_unchecked<I: SliceIndex<str>>(&self, i: I) -> &I::Output;
2103-
#[unstable(feature = "str_checked_slicing", issue = "39932")]
2103+
#[stable(feature = "str_checked_slicing", since = "1.20.0")]
21042104
unsafe fn get_unchecked_mut<I: SliceIndex<str>>(&mut self, i: I) -> &mut I::Output;
21052105
#[stable(feature = "core", since = "1.6.0")]
21062106
unsafe fn slice_unchecked(&self, begin: usize, end: usize) -> &str;

0 commit comments

Comments
 (0)