summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/typst-ide/src/analyze.rs2
-rw-r--r--crates/typst-layout/src/flow/compose.rs2
-rw-r--r--crates/typst-layout/src/grid/layouter.rs2
-rw-r--r--crates/typst-layout/src/math/stretch.rs2
-rw-r--r--crates/typst-library/src/foundations/cast.rs2
-rw-r--r--crates/typst-library/src/model/numbering.rs2
-rw-r--r--crates/typst-library/src/visualize/gradient.rs3
-rw-r--r--crates/typst-render/src/shape.rs8
8 files changed, 12 insertions, 11 deletions
diff --git a/crates/typst-ide/src/analyze.rs b/crates/typst-ide/src/analyze.rs
index 7ee83e70..c493da81 100644
--- a/crates/typst-ide/src/analyze.rs
+++ b/crates/typst-ide/src/analyze.rs
@@ -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);
}
}
diff --git a/crates/typst-layout/src/flow/compose.rs b/crates/typst-layout/src/flow/compose.rs
index 76af8f65..54dc487a 100644
--- a/crates/typst-layout/src/flow/compose.rs
+++ b/crates/typst-layout/src/flow/compose.rs
@@ -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();
diff --git a/crates/typst-layout/src/grid/layouter.rs b/crates/typst-layout/src/grid/layouter.rs
index af47ff72..dc9e2238 100644
--- a/crates/typst-layout/src/grid/layouter.rs
+++ b/crates/typst-layout/src/grid/layouter.rs
@@ -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.
diff --git a/crates/typst-layout/src/math/stretch.rs b/crates/typst-layout/src/math/stretch.rs
index dafa8cbe..f45035e2 100644
--- a/crates/typst-layout/src/math/stretch.rs
+++ b/crates/typst-layout/src/math/stretch.rs
@@ -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)
})
}
diff --git a/crates/typst-library/src/foundations/cast.rs b/crates/typst-library/src/foundations/cast.rs
index 38f409c6..73645491 100644
--- a/crates/typst-library/src/foundations/cast.rs
+++ b/crates/typst-library/src/foundations/cast.rs
@@ -21,7 +21,7 @@ use crate::foundations::{
///
/// Type casting works as follows:
/// - [`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`
/// (infallible)
/// - [`FromValue for T`](FromValue) is for conversion from `Value -> T`
diff --git a/crates/typst-library/src/model/numbering.rs b/crates/typst-library/src/model/numbering.rs
index 15050675..ada8a396 100644
--- a/crates/typst-library/src/model/numbering.rs
+++ b/crates/typst-library/src/model/numbering.rs
@@ -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),
diff --git a/crates/typst-library/src/visualize/gradient.rs b/crates/typst-library/src/visualize/gradient.rs
index 1a723a9f..d59175a4 100644
--- a/crates/typst-library/src/visualize/gradient.rs
+++ b/crates/typst-library/src/visualize/gradient.rs
@@ -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
diff --git a/crates/typst-render/src/shape.rs b/crates/typst-render/src/shape.rs
index ba7ed6d8..9b50d5f1 100644
--- a/crates/typst-render/src/shape.rs
+++ b/crates/typst-render/src/shape.rs
@@ -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(|| {