Skip to content

Commit e97ced7

Browse files
authored
Merge pull request #108 from kas-gui/clippy
Clippy
2 parents 64e7d1f + c4b7cca commit e97ced7

File tree

6 files changed

+67
-67
lines changed

6 files changed

+67
-67
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,4 @@ unit_arg = "allow"
6464
needless_lifetimes = "allow"
6565
neg_cmp_op_on_partial_ord = "allow"
6666
manual_range_contains = "allow"
67+
manual_is_multiple_of = "allow"

src/display/glyph_pos.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -229,21 +229,21 @@ impl<'a> GlyphRun<'a> {
229229
if !fmt.flags.is_empty() {
230230
let glyph = &self.run.glyphs[self.range.start()];
231231
let position = glyph.position + self.offset;
232-
if fmt.flags.contains(EffectFlags::UNDERLINE) {
233-
if let Some(metrics) = sf.underline_metrics() {
234-
let y_top = position.1 - metrics.position;
235-
let h = metrics.thickness;
236-
let x1 = position.0;
237-
underline = Some((x1, y_top, h, fmt.e));
238-
}
232+
if fmt.flags.contains(EffectFlags::UNDERLINE)
233+
&& let Some(metrics) = sf.underline_metrics()
234+
{
235+
let y_top = position.1 - metrics.position;
236+
let h = metrics.thickness;
237+
let x1 = position.0;
238+
underline = Some((x1, y_top, h, fmt.e));
239239
}
240-
if fmt.flags.contains(EffectFlags::STRIKETHROUGH) {
241-
if let Some(metrics) = sf.strikethrough_metrics() {
242-
let y_top = position.1 - metrics.position;
243-
let h = metrics.thickness;
244-
let x1 = position.0;
245-
strikethrough = Some((x1, y_top, h, fmt.e));
246-
}
240+
if fmt.flags.contains(EffectFlags::STRIKETHROUGH)
241+
&& let Some(metrics) = sf.strikethrough_metrics()
242+
{
243+
let y_top = position.1 - metrics.position;
244+
let h = metrics.thickness;
245+
let x1 = position.0;
246+
strikethrough = Some((x1, y_top, h, fmt.e));
247247
}
248248
}
249249

src/display/text_runs.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,12 @@ impl TextDisplay {
9393

9494
let mut font_tokens = text.font_tokens(dpem);
9595
let mut next_fmt = font_tokens.next();
96-
if let Some(fmt) = next_fmt.as_ref() {
97-
if fmt.start == 0 {
98-
font = fmt.font;
99-
dpem = fmt.dpem;
100-
next_fmt = font_tokens.next();
101-
}
96+
if let Some(fmt) = next_fmt.as_ref()
97+
&& fmt.start == 0
98+
{
99+
font = fmt.font;
100+
dpem = fmt.dpem;
101+
next_fmt = font_tokens.next();
102102
}
103103

104104
let fonts = fonts::library();
@@ -160,12 +160,12 @@ impl TextDisplay {
160160
// Force end of current run?
161161
let bidi_break = levels[index] != input.level;
162162

163-
if let Some(fmt) = next_fmt.as_ref() {
164-
if to_usize(fmt.start) == index {
165-
font = fmt.font;
166-
dpem = fmt.dpem;
167-
next_fmt = font_tokens.next();
168-
}
163+
if let Some(fmt) = next_fmt.as_ref()
164+
&& to_usize(fmt.start) == index
165+
{
166+
font = fmt.font;
167+
dpem = fmt.dpem;
168+
next_fmt = font_tokens.next();
169169
}
170170

171171
if input.script == UNKNOWN_SCRIPT && props.script().is_real() {
@@ -241,10 +241,10 @@ impl TextDisplay {
241241
};
242242

243243
let font_id = fonts.select_font(&font, input.script)?;
244-
if let Some(id) = face_id {
245-
if !fonts.contains_face(font_id, id).expect("invalid FontId") {
246-
face_id = None;
247-
}
244+
if let Some(id) = face_id
245+
&& !fonts.contains_face(font_id, id).expect("invalid FontId")
246+
{
247+
face_id = None;
248248
}
249249
let face_id =
250250
face_id.unwrap_or_else(|| fonts.first_face_for(font_id).expect("invalid FontId"));

src/display/wrap_lines.rs

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,11 @@ impl TextDisplay {
122122
_: PartMetrics,
123123
checkpoint: bool,
124124
) {
125-
if checkpoint {
126-
if let Some(index) = self.parts.last().cloned() {
127-
if index == run_index {
128-
return;
129-
}
130-
}
125+
if checkpoint
126+
&& let Some(index) = self.parts.last().cloned()
127+
&& index == run_index
128+
{
129+
return;
131130
}
132131

133132
self.parts.push(run_index);
@@ -443,27 +442,27 @@ impl PartAccumulator for LineAdder {
443442
let glyph_range = glyph_run.to_glyph_range(part_range);
444443

445444
let justify = self.h_align == Align::Stretch && part.len_no_space > 0.0;
446-
if checkpoint && !justify {
447-
if let Some(info) = self.parts.last_mut() {
448-
if info.run == run {
449-
// Merge into last part info (not strictly necessary)
450-
451-
if glyph_run.level.is_ltr() {
452-
info.glyph_range.end = glyph_range.end;
453-
} else {
454-
info.offset = part.offset;
455-
info.glyph_range.start = glyph_range.start;
456-
}
457-
debug_assert!(info.glyph_range.start <= info.glyph_range.end);
445+
if checkpoint
446+
&& !justify
447+
&& let Some(info) = self.parts.last_mut()
448+
&& info.run == run
449+
{
450+
// Merge into last part info (not strictly necessary)
458451

459-
if part.len_no_space > 0.0 {
460-
info.len_no_space = info.len + part.len_no_space;
461-
}
462-
info.len += part.len;
452+
if glyph_run.level.is_ltr() {
453+
info.glyph_range.end = glyph_range.end;
454+
} else {
455+
info.offset = part.offset;
456+
info.glyph_range.start = glyph_range.start;
457+
}
458+
debug_assert!(info.glyph_range.start <= info.glyph_range.end);
463459

464-
return;
465-
}
460+
if part.len_no_space > 0.0 {
461+
info.len_no_space = info.len + part.len_no_space;
466462
}
463+
info.len += part.len;
464+
465+
return;
467466
}
468467

469468
self.parts.push(PartInfo {

src/fonts/library.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -287,13 +287,13 @@ impl FontLibrary {
287287

288288
let faces = self.faces.read().unwrap();
289289

290-
if let Some(face_id) = last_face_id {
291-
if font.1.contains(&face_id) {
292-
let face = &faces.faces[face_id.get()];
293-
// TODO(opt): should we cache this lookup?
294-
if face.face.glyph_index(c).is_some() {
295-
return Ok(Some(face_id));
296-
}
290+
if let Some(face_id) = last_face_id
291+
&& font.1.contains(&face_id)
292+
{
293+
let face = &faces.faces[face_id.get()];
294+
// TODO(opt): should we cache this lookup?
295+
if face.face.glyph_index(c).is_some() {
296+
return Ok(Some(face_id));
297297
}
298298
}
299299

@@ -313,7 +313,7 @@ impl FontLibrary {
313313
// TODO: we need some mechanism to widen the search when this
314314
// fails (certain chars might only be found in a special font).
315315
if id.is_none() {
316-
id = font.1.first().map(|id| *id);
316+
id = font.1.first().copied();
317317
}
318318

319319
entry.insert(id);

src/format/markdown.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,11 @@ fn parse(input: &str) -> Result<Markdown, Error> {
128128
let mut fmt: Vec<Fmt> = Vec::new();
129129
let mut set_last = |item: &StackItem| {
130130
let f = Fmt::new(item);
131-
if let Some(last) = fmt.last_mut() {
132-
if last.start >= item.start {
133-
*last = f;
134-
return;
135-
}
131+
if let Some(last) = fmt.last_mut()
132+
&& last.start >= item.start
133+
{
134+
*last = f;
135+
return;
136136
}
137137
fmt.push(f);
138138
};

0 commit comments

Comments
 (0)