Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Use more specific panic message for &str slicing errors #38066
Separate out of bounds errors from character boundary errors, and print
It reports the first error it finds in:
killercup left a comment
Nice work! Handling the different cases with custom messages makes this much better.
As mentioned in #38052 I'd like to try and convey that indexing a string (slice) is done using byte offsets -- and not character offsets. I think this is one of those messages people will see this in failing tests and then have a hard time recognizing why this went wrong; and then have an even harder time to find a solution like the unicode-segmentation crate. UTF-8 is hard when people don't think about it.
I know putting all that in the panic message is not a solution; but maybe you can change it to "slicing at byte 4 which is not a char boundary" or something like that?
(By the way, is there a lint to catch statically known wrong string slices?)
@bors: retry * android timeout…
On Tue, Jan 3, 2017 at 12:54 PM, bors ***@***.***> wrote: