diff --git a/crates/typst-library/src/foundations/array.rs b/crates/typst-library/src/foundations/array.rs index 11c2220d7..87a301049 100644 --- a/crates/typst-library/src/foundations/array.rs +++ b/crates/typst-library/src/foundations/array.rs @@ -94,7 +94,7 @@ impl Array { } /// Iterate over references to the contained values. - pub fn iter(&self) -> std::slice::Iter { + pub fn iter(&self) -> std::slice::Iter<'_, Value> { self.0.iter() } diff --git a/crates/typst-library/src/foundations/dict.rs b/crates/typst-library/src/foundations/dict.rs index c93670c1d..ba161f44c 100644 --- a/crates/typst-library/src/foundations/dict.rs +++ b/crates/typst-library/src/foundations/dict.rs @@ -114,7 +114,7 @@ impl Dict { } /// Iterate over pairs of references to the contained keys and values. - pub fn iter(&self) -> indexmap::map::Iter { + pub fn iter(&self) -> indexmap::map::Iter<'_, Str, Value> { self.0.iter() } diff --git a/crates/typst-library/src/layout/container.rs b/crates/typst-library/src/layout/container.rs index 725f177b7..fc27644e2 100644 --- a/crates/typst-library/src/layout/container.rs +++ b/crates/typst-library/src/layout/container.rs @@ -497,7 +497,8 @@ mod callbacks { macro_rules! callback { ($name:ident = ($($param:ident: $param_ty:ty),* $(,)?) -> $ret:ty) => { - #[derive(Debug, Clone, PartialEq, Hash)] + #[derive(Debug, Clone, Hash)] + #[allow(clippy::derived_hash_with_manual_eq)] pub struct $name { captured: Content, f: fn(&Content, $($param_ty),*) -> $ret, @@ -535,6 +536,19 @@ mod callbacks { (self.f)(&self.captured, $($param),*) } } + + impl PartialEq for $name { + fn eq(&self, other: &Self) -> bool { + // Comparing function pointers is problematic. Since for + // each type of content, there is typically just one + // callback, we skip it. It barely matters anyway since + // getting into a comparison codepath for inline & block + // elements containing callback bodies is close to + // impossible (as these are generally generated in show + // rules). + self.captured.eq(&other.captured) + } + } }; } diff --git a/crates/typst-library/src/layout/fragment.rs b/crates/typst-library/src/layout/fragment.rs index c26661154..dd28191c5 100644 --- a/crates/typst-library/src/layout/fragment.rs +++ b/crates/typst-library/src/layout/fragment.rs @@ -47,12 +47,12 @@ impl Fragment { } /// Iterate over the contained frames. - pub fn iter(&self) -> std::slice::Iter { + pub fn iter(&self) -> std::slice::Iter<'_, Frame> { self.0.iter() } /// Iterate over the contained frames. - pub fn iter_mut(&mut self) -> std::slice::IterMut { + pub fn iter_mut(&mut self) -> std::slice::IterMut<'_, Frame> { self.0.iter_mut() } } diff --git a/crates/typst-library/src/text/mod.rs b/crates/typst-library/src/text/mod.rs index b1e381cb2..230f8e501 100644 --- a/crates/typst-library/src/text/mod.rs +++ b/crates/typst-library/src/text/mod.rs @@ -936,7 +936,7 @@ cast! { } /// Resolve a prioritized iterator over the font families. -pub fn families(styles: StyleChain) -> impl Iterator + Clone { +pub fn families(styles: StyleChain<'_>) -> impl Iterator + Clone { let fallbacks = singleton!(Vec, { [ "libertinus serif",