Skip to content

Commit b7f6a0b

Browse files
authored
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.
2 parents 356d1e9 + 66e9984 commit b7f6a0b

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/libcore/str/mod.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -2270,12 +2270,11 @@ impl str {
22702270
self.len() == 0
22712271
}
22722272

2273-
/// Checks that `index`-th byte lies at the start and/or end of a
2274-
/// UTF-8 code point sequence.
2273+
/// Checks that `index`-th byte is the first byte in a UTF-8 code point
2274+
/// sequence or the end of the string.
22752275
///
22762276
/// The start and end of the string (when `index == self.len()`) are
2277-
/// considered to be
2278-
/// boundaries.
2277+
/// considered to be boundaries.
22792278
///
22802279
/// Returns `false` if `index` is greater than `self.len()`.
22812280
///

0 commit comments

Comments
 (0)