Rollup merge of #113934 - ajtribick:string-pop-remove-multibyte, r=thomcc
Multibyte character removal in String::pop and String::remove doctests I think it would be useful to have the doctests for the `String::pop()` and `String::remove()` methods demonstrate that they work on multibyte UTF-8 sequences.
This commit is contained in:
commit
37cd63431c
@ -1290,11 +1290,11 @@ pub fn truncate(&mut self, new_len: usize) {
|
|||||||
/// Basic usage:
|
/// Basic usage:
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// let mut s = String::from("foo");
|
/// let mut s = String::from("abč");
|
||||||
///
|
///
|
||||||
/// assert_eq!(s.pop(), Some('o'));
|
/// assert_eq!(s.pop(), Some('č'));
|
||||||
/// assert_eq!(s.pop(), Some('o'));
|
/// assert_eq!(s.pop(), Some('b'));
|
||||||
/// assert_eq!(s.pop(), Some('f'));
|
/// assert_eq!(s.pop(), Some('a'));
|
||||||
///
|
///
|
||||||
/// assert_eq!(s.pop(), None);
|
/// assert_eq!(s.pop(), None);
|
||||||
/// ```
|
/// ```
|
||||||
@ -1324,11 +1324,11 @@ pub fn pop(&mut self) -> Option<char> {
|
|||||||
/// Basic usage:
|
/// Basic usage:
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// let mut s = String::from("foo");
|
/// let mut s = String::from("abç");
|
||||||
///
|
///
|
||||||
/// assert_eq!(s.remove(0), 'f');
|
/// assert_eq!(s.remove(0), 'a');
|
||||||
/// assert_eq!(s.remove(1), 'o');
|
/// assert_eq!(s.remove(1), 'ç');
|
||||||
/// assert_eq!(s.remove(0), 'o');
|
/// assert_eq!(s.remove(0), 'b');
|
||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
|
Loading…
Reference in New Issue
Block a user