about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorPiotr Czarnecki <pioczarn@gmail.com>2014-03-09 22:57:22 +0100
committerPiotr Czarnecki <pioczarn@gmail.com>2014-03-10 13:55:02 +0100
commitb0e855a7584b9893d9fe19d2eb9e7272e0c90a6f (patch)
tree9d568bb68964d3dca9d9b51227038c754ff0b898 /src/libstd
parent262d1543db6eba077e9f31a4e734c337746e7ea8 (diff)
downloadrust-b0e855a7584b9893d9fe19d2eb9e7272e0c90a6f.tar.gz
rust-b0e855a7584b9893d9fe19d2eb9e7272e0c90a6f.zip
libstd: Update docs for `slice_shift_char` and {shift,pop}_{char,byte}
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/str.rs27
1 files changed, 10 insertions, 17 deletions
diff --git a/src/libstd/str.rs b/src/libstd/str.rs
index f5bd7e75c3a..5bd14e717b1 100644
--- a/src/libstd/str.rs
+++ b/src/libstd/str.rs
@@ -1465,6 +1465,7 @@ pub mod raw {
     }
 
     /// Removes the last byte from a string and returns it.
+    /// Returns None when an empty string is passed.
     /// The caller must preserve the valid UTF-8 property.
     pub unsafe fn pop_byte(s: &mut ~str) -> Option<u8> {
         let len = s.len();
@@ -1478,6 +1479,7 @@ pub mod raw {
     }
 
     /// Removes the first byte from a string and returns it.
+    /// Returns None when an empty string is passed.
     /// The caller must preserve the valid UTF-8 property.
     pub unsafe fn shift_byte(s: &mut ~str) -> Option<u8> {
         let len = s.len();
@@ -2280,22 +2282,19 @@ pub trait StrSlice<'a> {
     /// Retrieves the first character from a string slice and returns
     /// it. This does not allocate a new string; instead, it returns a
     /// slice that point one character beyond the character that was
-    /// shifted.
-    ///
-    /// # Failure
-    ///
-    /// If the string does not contain any characters.
+    /// shifted. If the string does not contain any characters,
+    /// a tuple of None and an empty string is returned instead.
     ///
     /// # Example
     ///
     /// ```rust
     /// let s = "Löwe 老虎 Léopard";
     /// let (c, s1) = s.slice_shift_char();
-    /// assert_eq!(c, 'L');
+    /// assert_eq!(c, Some('L'));
     /// assert_eq!(s1, "öwe 老虎 Léopard");
     ///
     /// let (c, s2) = s1.slice_shift_char();
-    /// assert_eq!(c, 'ö');
+    /// assert_eq!(c, Some('ö'));
     /// assert_eq!(s2, "we 老虎 Léopard");
     /// ```
     fn slice_shift_char(&self) -> (Option<char>, &'a str);
@@ -2821,18 +2820,12 @@ pub trait OwnedStr {
     /// Appends a character to the back of a string
     fn push_char(&mut self, c: char);
 
-    /// Remove the final character from a string and return it
-    ///
-    /// # Failure
-    ///
-    /// If the string does not contain any characters
+    /// Remove the final character from a string and return it. Return None
+    /// when the string is empty.
     fn pop_char(&mut self) -> Option<char>;
 
-    /// Remove the first character from a string and return it
-    ///
-    /// # Failure
-    ///
-    /// If the string does not contain any characters
+    /// Remove the first character from a string and return it. Return None
+    /// when the string is empty.
     fn shift_char(&mut self) -> Option<char>;
 
     /// Prepend a char to a string