Skip to content

Commit e574cae

Browse files
committed
Fixup new clippy lints
These are slightly weird, but basically clippy now uses a heuristic to identify certain method calls that it expects to be resolve to a field access, and flags that these do not need to be wrapped in closures: rust-lang/rust-clippy#8109 (comment)
1 parent f76bea8 commit e574cae

File tree

4 files changed

+6
-7
lines changed

4 files changed

+6
-7
lines changed

piet-coregraphics/src/text.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -681,8 +681,7 @@ impl TextLayout for CoreGraphicsTextLayout {
681681
let utf16_range = line.get_string_range();
682682
let rel_offset = (n - utf16_range.location) as usize;
683683
metric.start_offset
684-
+ util::count_until_utf16(line_text, rel_offset)
685-
.unwrap_or_else(|| line_text.len())
684+
+ util::count_until_utf16(line_text, rel_offset).unwrap_or(line_text.len())
686685
}
687686
// some other value; should never happen
688687
_ => panic!("gross violation of api contract"),

piet-direct2d/src/text.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -385,8 +385,8 @@ impl TextLayout for D2DTextLayout {
385385
} as usize;
386386

387387
// Convert text position from utf-16 code units to utf-8 code units.
388-
let text_position = util::count_until_utf16(&self.text, text_position_16)
389-
.unwrap_or_else(|| self.text.len());
388+
let text_position =
389+
util::count_until_utf16(&self.text, text_position_16).unwrap_or(self.text.len());
390390

391391
HitTestPoint::new(text_position, htp.is_inside)
392392
}

piet-direct2d/src/text/lines.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ pub(crate) fn fetch_line_metrics(text: &str, layout: &dwrite::TextLayout) -> Vec
4040
// with offsets
4141
fn len_and_ws_len_utf8(s: &str, total_len_16: u32, ws_len_16: u32) -> (usize, usize) {
4242
let non_ws_len_16 = (total_len_16 - ws_len_16) as usize;
43-
let non_ws_len_8 = util::count_until_utf16(s, non_ws_len_16).unwrap_or_else(|| s.len());
43+
let non_ws_len_8 = util::count_until_utf16(s, non_ws_len_16).unwrap_or(s.len());
4444
let s = &s[non_ws_len_8..];
45-
let ws_len_8 = util::count_until_utf16(s, ws_len_16 as usize).unwrap_or_else(|| s.len());
45+
let ws_len_8 = util::count_until_utf16(s, ws_len_16 as usize).unwrap_or(s.len());
4646
(non_ws_len_8, ws_len_8)
4747
}
4848

piet-web/src/text/grapheme.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ pub(crate) fn get_grapheme_boundaries(
1818
) -> Option<GraphemeBoundaries> {
1919
let mut graphemes = UnicodeSegmentation::grapheme_indices(text, true);
2020
let (text_position, _) = graphemes.nth(grapheme_position)?;
21-
let (next_text_position, _) = graphemes.next().unwrap_or_else(|| (text.len(), ""));
21+
let (next_text_position, _) = graphemes.next().unwrap_or((text.len(), ""));
2222

2323
let curr_edge = hit_test_line_position(ctx, text, text_position);
2424
let next_edge = hit_test_line_position(ctx, text, next_text_position);

0 commit comments

Comments
 (0)