mirror of
https://github.com/typst/typst
synced 2025-05-13 12:36:23 +08:00
Fix cargo clippy
warnings (mostly about .repeat.take
and .next_back
) (#6038)
This commit is contained in:
parent
bd531e08dc
commit
3650859ae8
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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.
|
||||
|
@ -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)
|
||||
})
|
||||
}
|
||||
|
@ -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),
|
||||
|
||||
|
@ -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
|
||||
|
@ -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(|| {
|
||||
|
Loading…
x
Reference in New Issue
Block a user