Skip to content

Commit 542e41e

Browse files
committed
Apply clippy lints
1 parent fc99036 commit 542e41e

File tree

3 files changed

+11
-15
lines changed

3 files changed

+11
-15
lines changed

src/display_list/from_snippet.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ impl<'a> Iterator for CursorLines<'a> {
3939
ret
4040
})
4141
.or_else(|| {
42-
let ret = Some((&self.0[..], EndLine::EOF));
42+
let ret = Some((self.0, EndLine::EOF));
4343
self.0 = "";
4444
ret
4545
})
@@ -79,7 +79,7 @@ fn format_title(annotation: snippet::Annotation<'_>) -> DisplayLine<'_> {
7979
annotation: Annotation {
8080
annotation_type: DisplayAnnotationType::from(annotation.annotation_type),
8181
id: annotation.id,
82-
label: format_label(Some(&label), Some(DisplayTextStyle::Emphasis)),
82+
label: format_label(Some(label), Some(DisplayTextStyle::Emphasis)),
8383
},
8484
source_aligned: false,
8585
continuation: false,
@@ -182,7 +182,7 @@ fn fold_body(mut body: Vec<DisplayLine<'_>>) -> Vec<DisplayLine<'_>> {
182182
enum Line {
183183
Fold(usize),
184184
Source(usize),
185-
};
185+
}
186186

187187
let mut lines = vec![];
188188
let mut no_annotation_lines_counter = 0;
@@ -193,8 +193,8 @@ fn fold_body(mut body: Vec<DisplayLine<'_>>) -> Vec<DisplayLine<'_>> {
193193
line: DisplaySourceLine::Annotation { .. },
194194
..
195195
} => {
196+
let fold_start = idx - no_annotation_lines_counter;
196197
if no_annotation_lines_counter > 2 {
197-
let fold_start = idx - no_annotation_lines_counter;
198198
let fold_end = idx;
199199
let pre_len = if no_annotation_lines_counter > 8 {
200200
4
@@ -224,8 +224,7 @@ fn fold_body(mut body: Vec<DisplayLine<'_>>) -> Vec<DisplayLine<'_>> {
224224
lines.push(Line::Source(i));
225225
}
226226
} else {
227-
let start = idx - no_annotation_lines_counter;
228-
for (i, _) in body.iter().enumerate().take(idx).skip(start) {
227+
for (i, _) in body.iter().enumerate().take(idx).skip(fold_start) {
229228
lines.push(Line::Source(i));
230229
}
231230
}
@@ -377,7 +376,7 @@ fn format_body(
377376
annotation: Annotation {
378377
annotation_type,
379378
id: None,
380-
label: format_label(Some(&annotation.label), None),
379+
label: format_label(Some(annotation.label), None),
381380
},
382381
range,
383382
annotation_type: DisplayAnnotationType::from(
@@ -490,7 +489,7 @@ fn format_body(
490489
annotation: Annotation {
491490
annotation_type,
492491
id: None,
493-
label: format_label(Some(&annotation.label), None),
492+
label: format_label(Some(annotation.label), None),
494493
},
495494
range,
496495
annotation_type: DisplayAnnotationType::from(

src/formatter/mod.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ impl<'a> DisplayList<'a> {
132132
for fragment in label {
133133
match fragment.style {
134134
DisplayTextStyle::Regular => fragment.content.fmt(f)?,
135-
DisplayTextStyle::Emphasis => emphasis_style.paint(&fragment.content, f)?,
135+
DisplayTextStyle::Emphasis => emphasis_style.paint(fragment.content, f)?,
136136
}
137137
}
138138
Ok(())
@@ -298,7 +298,7 @@ impl<'a> DisplayList<'a> {
298298
f,
299299
)?;
300300

301-
if !is_annotation_empty(&annotation) {
301+
if !is_annotation_empty(annotation) {
302302
f.write_char(' ')?;
303303
color.paint_fn(
304304
Box::new(|f| {
@@ -361,18 +361,15 @@ impl<'a> DisplayList<'a> {
361361
if *source_aligned {
362362
if *continuation {
363363
format_repeat_char(' ', lineno_width + 3, f)?;
364-
self.format_annotation(annotation, *continuation, false, f)
365364
} else {
366365
let lineno_color = self.stylesheet.get_style(StyleClass::LineNo);
367366
format_repeat_char(' ', lineno_width, f)?;
368367
f.write_char(' ')?;
369368
lineno_color.paint("=", f)?;
370369
f.write_char(' ')?;
371-
self.format_annotation(annotation, *continuation, false, f)
372370
}
373-
} else {
374-
self.format_annotation(annotation, *continuation, false, f)
375371
}
372+
self.format_annotation(annotation, *continuation, false, f)
376373
}
377374
}
378375
}

tests/snippet/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ where
7474
label_right: usize,
7575
column_width: usize,
7676
max_line_len: usize,
77-
};
77+
}
7878

7979
Option::<Wrapper>::deserialize(deserializer).map(|opt_wrapped: Option<Wrapper>| {
8080
opt_wrapped.map(|wrapped: Wrapper| {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy