@@ -1465,6 +1465,7 @@ pub mod raw {
14651465 }
14661466
14671467 /// Removes the last byte from a string and returns it.
1468+ /// Returns None when an empty string is passed.
14681469 /// The caller must preserve the valid UTF-8 property.
14691470 pub unsafe fn pop_byte ( s : & mut ~str ) -> Option < u8 > {
14701471 let len = s. len ( ) ;
@@ -1478,6 +1479,7 @@ pub mod raw {
14781479 }
14791480
14801481 /// Removes the first byte from a string and returns it.
1482+ /// Returns None when an empty string is passed.
14811483 /// The caller must preserve the valid UTF-8 property.
14821484 pub unsafe fn shift_byte ( s : & mut ~str ) -> Option < u8 > {
14831485 let len = s. len ( ) ;
@@ -2280,22 +2282,19 @@ pub trait StrSlice<'a> {
22802282 /// Retrieves the first character from a string slice and returns
22812283 /// it. This does not allocate a new string; instead, it returns a
22822284 /// slice that point one character beyond the character that was
2283- /// shifted.
2284- ///
2285- /// # Failure
2286- ///
2287- /// If the string does not contain any characters.
2285+ /// shifted. If the string does not contain any characters,
2286+ /// a tuple of None and an empty string is returned instead.
22882287 ///
22892288 /// # Example
22902289 ///
22912290 /// ```rust
22922291 /// let s = "Löwe 老虎 Léopard";
22932292 /// let (c, s1) = s.slice_shift_char();
2294- /// assert_eq!(c, 'L');
2293+ /// assert_eq!(c, Some( 'L') );
22952294 /// assert_eq!(s1, "öwe 老虎 Léopard");
22962295 ///
22972296 /// let (c, s2) = s1.slice_shift_char();
2298- /// assert_eq!(c, 'ö');
2297+ /// assert_eq!(c, Some( 'ö') );
22992298 /// assert_eq!(s2, "we 老虎 Léopard");
23002299 /// ```
23012300 fn slice_shift_char( & self ) -> ( Option <char >, & ' a str ) ;
@@ -2821,18 +2820,12 @@ pub trait OwnedStr {
28212820 /// Appends a character to the back of a string
28222821 fn push_char( & mut self , c: char ) ;
28232822
2824- /// Remove the final character from a string and return it
2825- ///
2826- /// # Failure
2827- ///
2828- /// If the string does not contain any characters
2823+ /// Remove the final character from a string and return it. Return None
2824+ /// when the string is empty.
28292825 fn pop_char( & mut self ) -> Option <char >;
28302826
2831- /// Remove the first character from a string and return it
2832- ///
2833- /// # Failure
2834- ///
2835- /// If the string does not contain any characters
2827+ /// Remove the first character from a string and return it. Return None
2828+ /// when the string is empty.
28362829 fn shift_char( & mut self ) -> Option <char >;
28372830
28382831 /// Prepend a char to a string
0 commit comments