about summary refs log tree commit diff
path: root/src/libunicode
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2014-12-10 19:46:38 -0800
committerAlex Crichton <alex@alexcrichton.com>2014-12-21 23:31:42 -0800
commit082bfde412176249dc7328e771a2a15d202824cf (patch)
tree4df3816d6ffea2f52bf5fa51fe385806ed529ba7 /src/libunicode
parent4908017d59da8694b9ceaf743baf1163c1e19086 (diff)
Fallout of std::str stabilization
Diffstat (limited to 'src/libunicode')
-rw-r--r--src/libunicode/u_str.rs111
1 files changed, 9 insertions, 102 deletions
diff --git a/src/libunicode/u_str.rs b/src/libunicode/u_str.rs
index 5d7d2951628..7d59e3de7b1 100644
--- a/src/libunicode/u_str.rs
+++ b/src/libunicode/u_str.rs
@@ -15,22 +15,16 @@
 //! This module provides functionality to `str` that requires the Unicode methods provided by the
 //! UnicodeChar trait.
 
+use self::GraphemeState::*;
 use core::prelude::*;
 
 use core::char;
 use core::cmp;
-use core::iter::{DoubleEndedIterator, DoubleEndedIteratorExt};
-use core::iter::{Filter, AdditiveIterator, Iterator, IteratorExt};
 use core::iter::{Filter, AdditiveIterator};
-use core::kinds::Sized;
 use core::mem;
 use core::num::Int;
-use core::option::Option::{None, Some};
-use core::option::Option;
-use core::slice::SliceExt;
 use core::slice;
-use core::str::{CharSplits, StrPrelude};
-use core::str::{CharSplits};
+use core::str::CharSplits;
 
 use u_char::UnicodeChar;
 use tables::grapheme::GraphemeCat;
@@ -39,106 +33,20 @@ use tables::grapheme::GraphemeCat;
 /// FIXME: This should be opaque
 #[stable]
 pub struct Words<'a> {
-    inner: Filter<'a, &'a str, CharSplits<'a, |char|:'a -> bool>,
-                  fn(&&str) -> bool>,
+    inner: Filter<&'a str, CharSplits<'a, fn(char) -> bool>, fn(&&str) -> bool>,
 }
 
 /// Methods for Unicode string slices
+#[allow(missing_docs)] // docs in libcollections
 pub trait UnicodeStr for Sized? {
-    /// Returns an iterator over the
-    /// [grapheme clusters](http://www.unicode.org/reports/tr29/#Grapheme_Cluster_Boundaries)
-    /// of the string.
-    ///
-    /// If `is_extended` is true, the iterator is over the *extended grapheme clusters*;
-    /// otherwise, the iterator is over the *legacy grapheme clusters*.
-    /// [UAX#29](http://www.unicode.org/reports/tr29/#Grapheme_Cluster_Boundaries)
-    /// recommends extended grapheme cluster boundaries for general processing.
-    ///
-    /// # Example
-    ///
-    /// ```rust
-    /// let gr1 = "a\u{0310}e\u{0301}o\u{0308}\u{0332}".graphemes(true).collect::<Vec<&str>>();
-    /// let b: &[_] = &["a\u{0310}", "e\u{0301}", "o\u{0308}\u{0332}"];
-    /// assert_eq!(gr1.as_slice(), b);
-    /// let gr2 = "a\r\nb🇷🇺🇸🇹".graphemes(true).collect::<Vec<&str>>();
-    /// let b: &[_] = &["a", "\r\n", "b", "🇷🇺🇸🇹"];
-    /// assert_eq!(gr2.as_slice(), b);
-    /// ```
     fn graphemes<'a>(&'a self, is_extended: bool) -> Graphemes<'a>;
-
-    /// Returns an iterator over the grapheme clusters of self and their byte offsets.
-    /// See `graphemes()` method for more information.
-    ///
-    /// # Example
-    ///
-    /// ```rust
-    /// let gr_inds = "a̐éö̲\r\n".grapheme_indices(true).collect::<Vec<(uint, &str)>>();
-    /// let b: &[_] = &[(0u, "a̐"), (3, "é"), (6, "ö̲"), (11, "\r\n")];
-    /// assert_eq!(gr_inds.as_slice(), b);
-    /// ```
     fn grapheme_indices<'a>(&'a self, is_extended: bool) -> GraphemeIndices<'a>;
-
-    /// An iterator over the words of a string (subsequences separated
-    /// by any sequence of whitespace). Sequences of whitespace are
-    /// collapsed, so empty "words" are not included.
-    ///
-    /// # Example
-    ///
-    /// ```rust
-    /// let some_words = " Mary   had\ta little  \n\t lamb";
-    /// let v: Vec<&str> = some_words.words().collect();
-    /// assert_eq!(v, vec!["Mary", "had", "a", "little", "lamb"]);
-    /// ```
-    #[stable]
     fn words<'a>(&'a self) -> Words<'a>;
-
-    /// Returns true if the string contains only whitespace.
-    ///
-    /// Whitespace characters are determined by `char::is_whitespace`.
-    ///
-    /// # Example
-    ///
-    /// ```rust
-    /// assert!(" \t\n".is_whitespace());
-    /// assert!("".is_whitespace());
-    ///
-    /// assert!( !"abc".is_whitespace());
-    /// ```
     fn is_whitespace(&self) -> bool;
-
-    /// Returns true if the string contains only alphanumeric code
-    /// points.
-    ///
-    /// Alphanumeric characters are determined by `char::is_alphanumeric`.
-    ///
-    /// # Example
-    ///
-    /// ```rust
-    /// assert!("Löwe老虎Léopard123".is_alphanumeric());
-    /// assert!("".is_alphanumeric());
-    ///
-    /// assert!( !" &*~".is_alphanumeric());
-    /// ```
     fn is_alphanumeric(&self) -> bool;
-
-    /// Returns a string's displayed width in columns, treating control
-    /// characters as zero-width.
-    ///
-    /// `is_cjk` determines behavior for characters in the Ambiguous category:
-    /// if `is_cjk` is `true`, these are 2 columns wide; otherwise, they are 1.
-    /// In CJK locales, `is_cjk` should be `true`, else it should be `false`.
-    /// [Unicode Standard Annex #11](http://www.unicode.org/reports/tr11/)
-    /// recommends that these characters be treated as 1 column (i.e.,
-    /// `is_cjk` = `false`) if the locale is unknown.
     fn width(&self, is_cjk: bool) -> uint;
-
-    /// Returns a string with leading and trailing whitespace removed.
     fn trim<'a>(&'a self) -> &'a str;
-
-    /// Returns a string with leading whitespace removed.
     fn trim_left<'a>(&'a self) -> &'a str;
-
-    /// Returns a string with trailing whitespace removed.
     fn trim_right<'a>(&'a self) -> &'a str;
 }
 
@@ -471,10 +379,10 @@ pub fn utf8_char_width(b: u8) -> uint {
 /// Determines if a vector of `u16` contains valid UTF-16
 pub fn is_utf16(v: &[u16]) -> bool {
     let mut it = v.iter();
-    macro_rules! next ( ($ret:expr) => {
+    macro_rules! next { ($ret:expr) => {
             match it.next() { Some(u) => *u, None => return $ret }
         }
-    )
+    }
     loop {
         let u = next!(true);
 
@@ -513,7 +421,7 @@ impl Utf16Item {
     pub fn to_char_lossy(&self) -> char {
         match *self {
             Utf16Item::ScalarValue(c) => c,
-            Utf16Item::LoneSurrogate(_) => '\uFFFD'
+            Utf16Item::LoneSurrogate(_) => '\u{FFFD}'
         }
     }
 }
@@ -568,15 +476,14 @@ impl<'a> Iterator<Utf16Item> for Utf16Items<'a> {
 /// # Example
 ///
 /// ```rust
-/// use std::str;
-/// use std::str::{ScalarValue, LoneSurrogate};
+/// use unicode::str::Utf16Item::{ScalarValue, LoneSurrogate};
 ///
 /// // 𝄞mus<invalid>ic<invalid>
 /// let v = [0xD834, 0xDD1E, 0x006d, 0x0075,
 ///          0x0073, 0xDD1E, 0x0069, 0x0063,
 ///          0xD834];
 ///
-/// assert_eq!(str::utf16_items(&v).collect::<Vec<_>>(),
+/// assert_eq!(unicode::str::utf16_items(&v).collect::<Vec<_>>(),
 ///            vec![ScalarValue('𝄞'),
 ///                 ScalarValue('m'), ScalarValue('u'), ScalarValue('s'),
 ///                 LoneSurrogate(0xDD1E),