diff options
Diffstat (limited to 'library')
| -rw-r--r-- | library/src/compute/calc.rs | 2 | ||||
| -rw-r--r-- | library/src/layout/mod.rs | 4 | ||||
| -rw-r--r-- | library/src/layout/par.rs | 3 | ||||
| -rw-r--r-- | library/src/lib.rs | 1 | ||||
| -rw-r--r-- | library/src/math/row.rs | 8 | ||||
| -rw-r--r-- | library/src/meta/bibliography.rs | 2 | ||||
| -rw-r--r-- | library/src/meta/numbering.rs | 2 | ||||
| -rw-r--r-- | library/src/text/deco.rs | 6 | ||||
| -rw-r--r-- | library/src/text/raw.rs | 2 | ||||
| -rw-r--r-- | library/src/text/shaping.rs | 2 | ||||
| -rw-r--r-- | library/src/visualize/shape.rs | 1 |
11 files changed, 19 insertions, 14 deletions
diff --git a/library/src/compute/calc.rs b/library/src/compute/calc.rs index d5166449..35e7ddb8 100644 --- a/library/src/compute/calc.rs +++ b/library/src/compute/calc.rs @@ -71,7 +71,7 @@ cast_from_value! { v: i64 => Self(Value::Int(v.abs())), v: f64 => Self(Value::Float(v.abs())), v: Length => Self(Value::Length(v.try_abs() - .ok_or_else(|| "cannot take absolute value of this length")?)), + .ok_or("cannot take absolute value of this length")?)), v: Angle => Self(Value::Angle(v.abs())), v: Ratio => Self(Value::Ratio(v.abs())), v: Fr => Self(Value::Fraction(v.abs())), diff --git a/library/src/layout/mod.rs b/library/src/layout/mod.rs index 0fed1a34..e84e35fc 100644 --- a/library/src/layout/mod.rs +++ b/library/src/layout/mod.rs @@ -238,7 +238,7 @@ impl<'a, 'v, 't> Builder<'a, 'v, 't> { Self { vt, scratch, - doc: top.then(|| DocBuilder::default()), + doc: top.then(DocBuilder::default), flow: FlowBuilder::default(), par: ParBuilder::default(), list: ListBuilder::default(), @@ -295,7 +295,7 @@ impl<'a, 'v, 't> Builder<'a, 'v, 't> { .to::<PagebreakElem>() .map_or(false, |pagebreak| !pagebreak.weak(styles)); - self.interrupt_page(keep.then(|| styles))?; + self.interrupt_page(keep.then_some(styles))?; if let Some(doc) = &mut self.doc { if doc.accept(content, styles) { diff --git a/library/src/layout/par.rs b/library/src/layout/par.rs index 011502e6..5d33de40 100644 --- a/library/src/layout/par.rs +++ b/library/src/layout/par.rs @@ -135,6 +135,7 @@ impl ParElem { expand: bool, ) -> SourceResult<Fragment> { #[comemo::memoize] + #[allow(clippy::too_many_arguments)] fn cached( par: &ParElem, world: Tracked<dyn World>, @@ -760,7 +761,7 @@ fn shared_get<T: PartialEq>( .iter() .filter_map(|child| child.to_styled()) .all(|(_, local)| getter(styles.chain(local)) == value) - .then(|| value) + .then_some(value) } /// Find suitable linebreaks. diff --git a/library/src/lib.rs b/library/src/lib.rs index 9b4e9644..caf76ded 100644 --- a/library/src/lib.rs +++ b/library/src/lib.rs @@ -1,3 +1,4 @@ +#![allow(clippy::wildcard_in_or_patterns)] //! Typst's standard library. pub mod compute; diff --git a/library/src/math/row.rs b/library/src/math/row.rs index ce9bc94a..0b0578aa 100644 --- a/library/src/math/row.rs +++ b/library/src/math/row.rs @@ -9,12 +9,12 @@ pub struct MathRow(Vec<MathFragment>); impl MathRow { pub fn new(fragments: Vec<MathFragment>) -> Self { - let mut iter = fragments.into_iter().peekable(); + let iter = fragments.into_iter().peekable(); let mut last: Option<usize> = None; let mut space: Option<MathFragment> = None; let mut resolved: Vec<MathFragment> = vec![]; - while let Some(mut fragment) = iter.next() { + for mut fragment in iter { match fragment { // Keep space only if supported by spaced fragments. MathFragment::Space(_) => { @@ -180,9 +180,9 @@ impl MathRow { } } - let mut fragments = self.0.into_iter().peekable(); + let fragments = self.0.into_iter().peekable(); let mut i = 0; - while let Some(fragment) = fragments.next() { + for fragment in fragments { if matches!(fragment, MathFragment::Align) { if let Some(&point) = points.get(i) { x = point; diff --git a/library/src/meta/bibliography.rs b/library/src/meta/bibliography.rs index 8fa2ee34..2f9a099e 100644 --- a/library/src/meta/bibliography.rs +++ b/library/src/meta/bibliography.rs @@ -489,7 +489,7 @@ fn create( &mut *citation_style, &[Citation { entry, - supplement: supplement.is_some().then(|| SUPPLEMENT), + supplement: supplement.is_some().then_some(SUPPLEMENT), }], ) .display; diff --git a/library/src/meta/numbering.rs b/library/src/meta/numbering.rs index f0a1c34e..b5416f68 100644 --- a/library/src/meta/numbering.rs +++ b/library/src/meta/numbering.rs @@ -149,7 +149,7 @@ impl NumberingPattern { /// Apply the pattern to the given number. pub fn apply(&self, numbers: &[usize]) -> EcoString { let mut fmt = EcoString::new(); - let mut numbers = numbers.into_iter(); + let mut numbers = numbers.iter(); for (i, ((prefix, kind, case), &n)) in self.pieces.iter().zip(&mut numbers).enumerate() diff --git a/library/src/text/deco.rs b/library/src/text/deco.rs index ab89e6b5..7b90b22f 100644 --- a/library/src/text/deco.rs +++ b/library/src/text/deco.rs @@ -315,11 +315,13 @@ pub(super) fn decorate( // Only do the costly segments intersection test if the line // intersects the bounding box. - if bbox.map_or(false, |bbox| { + let intersect = bbox.map_or(false, |bbox| { let y_min = -text.font.to_em(bbox.y_max).at(text.size); let y_max = -text.font.to_em(bbox.y_min).at(text.size); offset >= y_min && offset <= y_max - }) { + }); + + if intersect { // Find all intersections of segments with the line. intersections.extend( path.segments() diff --git a/library/src/text/raw.rs b/library/src/text/raw.rs index c6fba253..6d90bc5b 100644 --- a/library/src/text/raw.rs +++ b/library/src/text/raw.rs @@ -285,7 +285,7 @@ fn to_syn(RgbaColor { r, g, b, a }: RgbaColor) -> synt::Color { /// The syntect syntax definitions. static SYNTAXES: Lazy<syntect::parsing::SyntaxSet> = - Lazy::new(|| syntect::parsing::SyntaxSet::load_defaults_nonewlines()); + Lazy::new(syntect::parsing::SyntaxSet::load_defaults_nonewlines); /// The default theme used for syntax highlighting. pub static THEME: Lazy<synt::Theme> = Lazy::new(|| synt::Theme { diff --git a/library/src/text/shaping.rs b/library/src/text/shaping.rs index 0e5e0a73..50c4bcbd 100644 --- a/library/src/text/shaping.rs +++ b/library/src/text/shaping.rs @@ -379,7 +379,7 @@ impl<'a> ShapedText<'a> { // RTL needs offset one because the left side of the range should be // exclusive and the right side inclusive, contrary to the normal // behaviour of ranges. - self.glyphs[idx].safe_to_break.then(|| idx + (!ltr) as usize) + self.glyphs[idx].safe_to_break.then_some(idx + usize::from(!ltr)) } } diff --git a/library/src/visualize/shape.rs b/library/src/visualize/shape.rs index e0214f03..48c4d7a3 100644 --- a/library/src/visualize/shape.rs +++ b/library/src/visualize/shape.rs @@ -477,6 +477,7 @@ impl Layout for CircleElem { } /// Layout a shape. +#[allow(clippy::too_many_arguments)] fn layout( vt: &mut Vt, styles: StyleChain, |
