update char_indices example to highlight big chars
This commit is contained in:
parent
eff3de0927
commit
ac15a2e5a2
@ -719,13 +719,17 @@ impl str {
|
||||
/// Remember, [`char`]s may not match your human intuition about characters:
|
||||
///
|
||||
/// ```
|
||||
/// let y = "y̆";
|
||||
/// let yes = "y̆es";
|
||||
///
|
||||
/// let mut char_indices = y.char_indices();
|
||||
/// let mut char_indices = yes.char_indices();
|
||||
///
|
||||
/// assert_eq!(Some((0, 'y')), char_indices.next()); // not (0, 'y̆')
|
||||
/// assert_eq!(Some((1, '\u{0306}')), char_indices.next());
|
||||
///
|
||||
/// // note the 3 here - the last character took up two bytes
|
||||
/// assert_eq!(Some((3, 'e')), char_indices.next());
|
||||
/// assert_eq!(Some((4, 's')), char_indices.next());
|
||||
///
|
||||
/// assert_eq!(None, char_indices.next());
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
|
Loading…
x
Reference in New Issue
Block a user