//! is the same as `&[u8]`.
#![doc(primitive = "str")]
+#![stable]
use self::RecompositionState::*;
use self::DecompositionType::*;
*/
/// Any string that can be represented as a slice.
+#[stable]
pub trait StrExt for Sized?: ops::Slice<uint, str> {
/// Escapes each char in `s` with `char::escape_default`.
#[unstable = "return type may change to be an iterator"]
}
}
+#[stable]
impl StrExt for str {}
#[cfg(test)]
/// 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.
///
///
/// 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) })
///
/// Created with the method `.chars()`.
#[derive(Clone, Copy)]
+#[stable]
pub struct Chars<'a> {
iter: slice::Iter<'a, u8>
}
/// 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>,
/// 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,
/// 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,
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;