From 267b73d95e4fcc906e1b1207ab610fa45f6e6613 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Sun, 4 Jan 2015 23:32:20 -0800 Subject: [PATCH] std: Fixup some missing stabilization on str * The `str` module itself is stable. * The `StrExt` trait is stable (and impls). * The `Utf8Error` type is unstable. * The `from_utf8` function is stable * Some iterators are now stable: * `Chars` * `CharIndices` * The `MatchIndices` iterator is now unstable * The public `traits` module is no longer public. --- src/libcollections/str.rs | 3 +++ src/libcore/str/mod.rs | 10 +++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/libcollections/str.rs b/src/libcollections/str.rs index ed6a957d2acf..fee06422fdd1 100644 --- a/src/libcollections/str.rs +++ b/src/libcollections/str.rs @@ -50,6 +50,7 @@ //! is the same as `&[u8]`. #![doc(primitive = "str")] +#![stable] use self::RecompositionState::*; use self::DecompositionType::*; @@ -401,6 +402,7 @@ Section: Trait implementations */ /// Any string that can be represented as a slice. +#[stable] pub trait StrExt for Sized?: ops::Slice { /// Escapes each char in `s` with `char::escape_default`. #[unstable = "return type may change to be an iterator"] @@ -1340,6 +1342,7 @@ pub trait StrExt for Sized?: ops::Slice { } } +#[stable] impl StrExt for str {} #[cfg(test)] diff --git a/src/libcore/str/mod.rs b/src/libcore/str/mod.rs index d069744f8da5..964e0089e44e 100644 --- a/src/libcore/str/mod.rs +++ b/src/libcore/str/mod.rs @@ -142,6 +142,7 @@ Section: Creating a string /// Errors which can occur when attempting to interpret a byte slice as a `str`. #[derive(Copy, Eq, PartialEq, Clone)] +#[unstable = "error enumeration recently added and definitions may be refined"] pub enum Utf8Error { /// An invalid byte was detected at the byte offset given. /// @@ -165,6 +166,7 @@ pub enum Utf8Error { /// /// Returns `Err` if the slice is not utf-8 with a description as to why the /// provided slice is not utf-8. +#[stable] pub fn from_utf8(v: &[u8]) -> Result<&str, Utf8Error> { try!(run_utf8_validation_iterator(&mut v.iter())); Ok(unsafe { from_utf8_unchecked(v) }) @@ -247,6 +249,7 @@ Section: Iterators /// /// Created with the method `.chars()`. #[derive(Clone, Copy)] +#[stable] pub struct Chars<'a> { iter: slice::Iter<'a, u8> } @@ -356,6 +359,7 @@ impl<'a> DoubleEndedIterator for Chars<'a> { /// External iterator for a string's characters and their byte offsets. /// Use with the `std::iter` module. #[derive(Clone)] +#[stable] pub struct CharIndices<'a> { front_offset: uint, iter: Chars<'a>, @@ -848,6 +852,7 @@ impl Searcher { /// An iterator over the start and end indices of the matches of a /// substring within a larger string #[derive(Clone)] +#[unstable = "type may be removed"] pub struct MatchIndices<'a> { // constants haystack: &'a str, @@ -858,7 +863,7 @@ pub struct MatchIndices<'a> { /// An iterator over the substrings of a string separated by a given /// search string #[derive(Clone)] -#[unstable = "Type might get removed"] +#[unstable = "type may be removed"] pub struct SplitStr<'a> { it: MatchIndices<'a>, last_end: uint, @@ -1056,8 +1061,7 @@ const TAG_CONT_U8: u8 = 0b1000_0000u8; Section: Trait implementations */ -#[allow(missing_docs)] -pub mod traits { +mod traits { use cmp::{Ordering, Ord, PartialEq, PartialOrd, Eq}; use cmp::Ordering::{Less, Equal, Greater}; use iter::IteratorExt;