@@ -1465,6 +1465,7 @@ pub mod raw {
1465
1465
}
1466
1466
1467
1467
/// Removes the last byte from a string and returns it.
1468
+ /// Returns None when an empty string is passed.
1468
1469
/// The caller must preserve the valid UTF-8 property.
1469
1470
pub unsafe fn pop_byte ( s : & mut ~str ) -> Option < u8 > {
1470
1471
let len = s. len ( ) ;
@@ -1478,6 +1479,7 @@ pub mod raw {
1478
1479
}
1479
1480
1480
1481
/// Removes the first byte from a string and returns it.
1482
+ /// Returns None when an empty string is passed.
1481
1483
/// The caller must preserve the valid UTF-8 property.
1482
1484
pub unsafe fn shift_byte ( s : & mut ~str ) -> Option < u8 > {
1483
1485
let len = s. len ( ) ;
@@ -2280,22 +2282,19 @@ pub trait StrSlice<'a> {
2280
2282
/// Retrieves the first character from a string slice and returns
2281
2283
/// it. This does not allocate a new string; instead, it returns a
2282
2284
/// 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.
2288
2287
///
2289
2288
/// # Example
2290
2289
///
2291
2290
/// ```rust
2292
2291
/// let s = "Löwe 老虎 Léopard";
2293
2292
/// let (c, s1) = s.slice_shift_char();
2294
- /// assert_eq!(c, 'L');
2293
+ /// assert_eq!(c, Some( 'L') );
2295
2294
/// assert_eq!(s1, "öwe 老虎 Léopard");
2296
2295
///
2297
2296
/// let (c, s2) = s1.slice_shift_char();
2298
- /// assert_eq!(c, 'ö');
2297
+ /// assert_eq!(c, Some( 'ö') );
2299
2298
/// assert_eq!(s2, "we 老虎 Léopard");
2300
2299
/// ```
2301
2300
fn slice_shift_char( & self ) -> ( Option <char >, & ' a str ) ;
@@ -2821,18 +2820,12 @@ pub trait OwnedStr {
2821
2820
/// Appends a character to the back of a string
2822
2821
fn push_char( & mut self , c: char ) ;
2823
2822
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.
2829
2825
fn pop_char( & mut self ) -> Option <char >;
2830
2826
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.
2836
2829
fn shift_char( & mut self ) -> Option <char >;
2837
2830
2838
2831
/// Prepend a char to a string
0 commit comments