diff options
| author | bors <bors@rust-lang.org> | 2017-01-03 23:51:42 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2017-01-03 23:51:42 +0000 |
| commit | 468227129d08b52c4cf90313b29fdad1b80e596b (patch) | |
| tree | 395f940c4de2fd358f5777c4f28b867a4174e2b6 /src/doc/book | |
| parent | 8f62c2920077eb5cb81323142fc5dbe6ae8813c0 (diff) | |
| parent | d83fff3b3b9dd0fd6eef862e97f883d171367041 (diff) | |
| download | rust-468227129d08b52c4cf90313b29fdad1b80e596b.tar.gz rust-468227129d08b52c4cf90313b29fdad1b80e596b.zip | |
Auto merge of #38066 - bluss:string-slice-error, r=sfackler
Use more specific panic message for &str slicing errors
Separate out of bounds errors from character boundary errors, and print
more details for character boundary errors.
It reports the first error it finds in:
1. begin out of bounds
2. end out of bounds
3. begin <= end violated
3. begin not char boundary
5. end not char boundary.
Example:
&"abcαβγ"[..4]
thread 'str::test_slice_fail_boundary_1' panicked at 'byte index 4 is not
a char boundary; it is inside 'α' (bytes 3..5) of `abcαβγ`'
Fixes #38052
Diffstat (limited to 'src/doc/book')
| -rw-r--r-- | src/doc/book/strings.md | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/doc/book/strings.md b/src/doc/book/strings.md index 6af15d87683..a2146b669e3 100644 --- a/src/doc/book/strings.md +++ b/src/doc/book/strings.md @@ -163,8 +163,8 @@ let hachi = &dog[0..2]; with this error: ```text -thread 'main' panicked at 'index 0 and/or 2 in `忠犬ハチ公` do not lie on -character boundary' +thread 'main' panicked at 'byte index 2 is not a char boundary; it is inside '忠' +(bytes 0..3) of `忠犬ハチ公`' ``` ## Concatenation |
