Rollup merge of #72773 - Rantanen:is_char_boundary-docs, r=joshtriplett

Fix is_char_boundary documentation

Given the "start _and/or end_" wording in the original, the way I understood it was that the `str::is_char_boundary` method would also return `true` for the last byte in a UTF-8 code point sequence. (Which would have meant that for a string consisting of nothing but 1 and 2 byte UTF-8 code point sequences, it would return nothing but `true`.)

In practice the method returns `true` only for the starting byte of each sequence and the end of the string: [Playground](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=e9f5fc4d6bf2f1bf57a75f3c9a180770)

I was also somewhat tempted to remove the _The start and end of the string are considered to be boundaries_, since that's implied by the first sentence, but I decided to avoid bikeshedding over it and left it as it was since it's not wrong in relation to how the method behaves.
This commit is contained in:
Ralf Jung 2020-05-30 23:09:02 +02:00 committed by GitHub
commit b7f6a0b322
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2270,12 +2270,11 @@ pub const fn is_empty(&self) -> bool {
self.len() == 0
}
/// Checks that `index`-th byte lies at the start and/or end of a
/// UTF-8 code point sequence.
/// Checks that `index`-th byte is the first byte in a UTF-8 code point
/// sequence or the end of the string.
///
/// The start and end of the string (when `index == self.len()`) are
/// considered to be
/// boundaries.
/// considered to be boundaries.
///
/// Returns `false` if `index` is greater than `self.len()`.
///