Merge c317e5e2219b937d6a65517d78c6ac652fec9bea into 36ecbb2c8dccc1a31c43fee1466f1425844d8607

This commit is contained in:
frozolotl 2025-07-07 20:23:16 +00:00 committed by GitHub
commit ce0c8765e2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 26 additions and 1 deletions

View File

@ -500,7 +500,11 @@ impl PlainText for Packed<RawElem> {
}
/// The content of the raw text.
#[derive(Debug, Clone, Hash, PartialEq)]
#[derive(Debug, Clone, Hash)]
#[allow(
clippy::derived_hash_with_manual_eq,
reason = "https://github.com/typst/typst/pull/6560#issuecomment-3045393640"
)]
pub enum RawContent {
/// From a string.
Text(EcoString),
@ -525,6 +529,22 @@ impl RawContent {
}
}
impl PartialEq for RawContent {
fn eq(&self, other: &Self) -> bool {
match (self, other) {
(RawContent::Text(a), RawContent::Text(b)) => a == b,
(lines @ RawContent::Lines(_), RawContent::Text(text))
| (RawContent::Text(text), lines @ RawContent::Lines(_)) => {
*text == lines.get()
}
(RawContent::Lines(a), RawContent::Lines(b)) => Iterator::eq(
a.iter().map(|(line, _)| line),
b.iter().map(|(line, _)| line),
),
}
}
}
cast! {
RawContent,
self => self.get().into_value(),

View File

@ -687,6 +687,11 @@ a b c --------------------
#let hi = "你好world"
```
--- issue-6559-equality-between-raws ---
#test(`foo`, `foo`)
#assert.ne(`foo`, `bar`)
--- raw-theme-set-to-auto ---
```typ
#let hi = "Hello World"