We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 733c6f6 commit d466fd0Copy full SHA for d466fd0
src/str.rs
@@ -35,12 +35,13 @@ fn find_char_midpoint(chars: &str) -> usize {
35
// character boundary. So we look at the raw bytes, first scanning
36
// forward from the midpoint for a boundary, then trying backward.
37
let (left, right) = chars.as_bytes().split_at(mid);
38
- right.iter()
39
- .cloned()
40
- .position(is_char_boundary)
41
- .map(|i| mid + i)
42
- .or_else(|| left.iter().cloned().rposition(is_char_boundary))
43
- .unwrap_or(0)
+ match right.iter().cloned().position(is_char_boundary) {
+ Some(i) => mid + i,
+ None => left.iter()
+ .cloned()
+ .rposition(is_char_boundary)
+ .unwrap_or(0),
44
+ }
45
}
46
47
/// Try to split a string near the midpoint.
0 commit comments