diff options
| author | QuietMisdreavus <QuietMisdreavus@users.noreply.github.com> | 2017-12-27 16:27:57 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-12-27 16:27:57 -0600 |
| commit | ac15a2e5a291138fa06f1589aaa1f350e7894843 (patch) | |
| tree | cedd2eaee9b5f301b91929dd9c1bb7b49bba86d6 /src/liballoc | |
| parent | eff3de0927c36e6483ccb8a35c3d2da6e063de0b (diff) | |
| download | rust-ac15a2e5a291138fa06f1589aaa1f350e7894843.tar.gz rust-ac15a2e5a291138fa06f1589aaa1f350e7894843.zip | |
update char_indices example to highlight big chars
Diffstat (limited to 'src/liballoc')
| -rw-r--r-- | src/liballoc/str.rs | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/liballoc/str.rs b/src/liballoc/str.rs index 7fa872f4ded..a00e3d17dd0 100644 --- a/src/liballoc/str.rs +++ b/src/liballoc/str.rs @@ -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")] |
