mirror of
https://github.com/typst/typst
synced 2025-05-13 20:46: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()),
|
ast::Expr::Str(v) => Value::Str(v.get().into()),
|
||||||
_ => {
|
_ => {
|
||||||
if node.kind() == SyntaxKind::Contextual {
|
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);
|
return analyze_expr(world, &child);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -115,7 +115,7 @@ impl<'a, 'b> Composer<'a, 'b, '_, '_> {
|
|||||||
let column_height = regions.size.y;
|
let column_height = regions.size.y;
|
||||||
let backlog: Vec<_> = std::iter::once(&column_height)
|
let backlog: Vec<_> = std::iter::once(&column_height)
|
||||||
.chain(regions.backlog)
|
.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)
|
.skip(1)
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
|
@ -1469,7 +1469,7 @@ impl<'a> GridLayouter<'a> {
|
|||||||
// last height is the one for the current region.
|
// last height is the one for the current region.
|
||||||
rowspan
|
rowspan
|
||||||
.heights
|
.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
|
// Ensure that, in this region, the rowspan will span at least
|
||||||
// this row.
|
// this row.
|
||||||
|
@ -302,6 +302,6 @@ fn assemble(
|
|||||||
fn parts(assembly: GlyphAssembly, repeat: usize) -> impl Iterator<Item = GlyphPart> + '_ {
|
fn parts(assembly: GlyphAssembly, repeat: usize) -> impl Iterator<Item = GlyphPart> + '_ {
|
||||||
assembly.parts.into_iter().flat_map(move |part| {
|
assembly.parts.into_iter().flat_map(move |part| {
|
||||||
let count = if part.part_flags.extender() { repeat } else { 1 };
|
let count = if part.part_flags.extender() { repeat } else { 1 };
|
||||||
std::iter::repeat(part).take(count)
|
std::iter::repeat_n(part, count)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ use crate::foundations::{
|
|||||||
///
|
///
|
||||||
/// Type casting works as follows:
|
/// Type casting works as follows:
|
||||||
/// - [`Reflect for T`](Reflect) describes the possible Typst values for `T`
|
/// - [`Reflect for T`](Reflect) describes the possible Typst values for `T`
|
||||||
/// (for documentation and autocomplete).
|
/// (for documentation and autocomplete).
|
||||||
/// - [`IntoValue for T`](IntoValue) is for conversion from `T -> Value`
|
/// - [`IntoValue for T`](IntoValue) is for conversion from `T -> Value`
|
||||||
/// (infallible)
|
/// (infallible)
|
||||||
/// - [`FromValue for T`](FromValue) is for conversion from `Value -> T`
|
/// - [`FromValue for T`](FromValue) is for conversion from `Value -> T`
|
||||||
|
@ -394,7 +394,7 @@ impl NumberingKind {
|
|||||||
const SYMBOLS: &[char] = &['*', '†', '‡', '§', '¶', '‖'];
|
const SYMBOLS: &[char] = &['*', '†', '‡', '§', '¶', '‖'];
|
||||||
let symbol = SYMBOLS[(n - 1) % SYMBOLS.len()];
|
let symbol = SYMBOLS[(n - 1) % SYMBOLS.len()];
|
||||||
let amount = ((n - 1) / SYMBOLS.len()) + 1;
|
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),
|
Self::Hebrew => hebrew_numeral(n),
|
||||||
|
|
||||||
|
@ -574,8 +574,7 @@ impl Gradient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let n = repetitions.v;
|
let n = repetitions.v;
|
||||||
let mut stops = std::iter::repeat(self.stops_ref())
|
let mut stops = std::iter::repeat_n(self.stops_ref(), n)
|
||||||
.take(n)
|
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.flat_map(|(i, stops)| {
|
.flat_map(|(i, stops)| {
|
||||||
let mut stops = 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 dash = dash.as_ref().and_then(to_sk_dash_pattern);
|
||||||
|
|
||||||
let bbox = shape.geometry.bbox_size();
|
let bbox = shape.geometry.bbox_size();
|
||||||
let offset_bbox = (!matches!(shape.geometry, Geometry::Line(..)))
|
let offset_bbox = if !matches!(shape.geometry, Geometry::Line(..)) {
|
||||||
.then(|| offset_bounding_box(bbox, *thickness))
|
offset_bounding_box(bbox, *thickness)
|
||||||
.unwrap_or(bbox);
|
} else {
|
||||||
|
bbox
|
||||||
|
};
|
||||||
|
|
||||||
let fill_transform =
|
let fill_transform =
|
||||||
(!matches!(shape.geometry, Geometry::Line(..))).then(|| {
|
(!matches!(shape.geometry, Geometry::Line(..))).then(|| {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user