Fix cargo clippy warnings (mostly about .repeat.take and .next_back) (#6038)

This commit is contained in:
evie 2025-03-11 03:00:53 -07:00 committed by GitHub
parent bd531e08dc
commit 3650859ae8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 12 additions and 11 deletions

View File

@ -26,7 +26,7 @@ pub fn analyze_expr(
ast::Expr::Str(v) => Value::Str(v.get().into()),
_ => {
if node.kind() == SyntaxKind::Contextual {
if let Some(child) = node.children().last() {
if let Some(child) = node.children().next_back() {
return analyze_expr(world, &child);
}
}

View File

@ -115,7 +115,7 @@ impl<'a, 'b> Composer<'a, 'b, '_, '_> {
let column_height = regions.size.y;
let backlog: Vec<_> = std::iter::once(&column_height)
.chain(regions.backlog)
.flat_map(|&h| std::iter::repeat(h).take(self.config.columns.count))
.flat_map(|&h| std::iter::repeat_n(h, self.config.columns.count))
.skip(1)
.collect();

View File

@ -1469,7 +1469,7 @@ impl<'a> GridLayouter<'a> {
// last height is the one for the current region.
rowspan
.heights
.extend(std::iter::repeat(Abs::zero()).take(amount_missing_heights));
.extend(std::iter::repeat_n(Abs::zero(), amount_missing_heights));
// Ensure that, in this region, the rowspan will span at least
// this row.

View File

@ -302,6 +302,6 @@ fn assemble(
fn parts(assembly: GlyphAssembly, repeat: usize) -> impl Iterator<Item = GlyphPart> + '_ {
assembly.parts.into_iter().flat_map(move |part| {
let count = if part.part_flags.extender() { repeat } else { 1 };
std::iter::repeat(part).take(count)
std::iter::repeat_n(part, count)
})
}

View File

@ -394,7 +394,7 @@ impl NumberingKind {
const SYMBOLS: &[char] = &['*', '†', '‡', '§', '¶', '‖'];
let symbol = SYMBOLS[(n - 1) % SYMBOLS.len()];
let amount = ((n - 1) / SYMBOLS.len()) + 1;
std::iter::repeat(symbol).take(amount).collect()
std::iter::repeat_n(symbol, amount).collect()
}
Self::Hebrew => hebrew_numeral(n),

View File

@ -574,8 +574,7 @@ impl Gradient {
}
let n = repetitions.v;
let mut stops = std::iter::repeat(self.stops_ref())
.take(n)
let mut stops = std::iter::repeat_n(self.stops_ref(), n)
.enumerate()
.flat_map(|(i, stops)| {
let mut stops = stops

View File

@ -69,9 +69,11 @@ pub fn render_shape(canvas: &mut sk::Pixmap, state: State, shape: &Shape) -> Opt
let dash = dash.as_ref().and_then(to_sk_dash_pattern);
let bbox = shape.geometry.bbox_size();
let offset_bbox = (!matches!(shape.geometry, Geometry::Line(..)))
.then(|| offset_bounding_box(bbox, *thickness))
.unwrap_or(bbox);
let offset_bbox = if !matches!(shape.geometry, Geometry::Line(..)) {
offset_bounding_box(bbox, *thickness)
} else {
bbox
};
let fill_transform =
(!matches!(shape.geometry, Geometry::Line(..))).then(|| {