Improve error messages

Using "codepoint" is more accurate and lines up with what typst's standard library uses
This commit is contained in:
T0mstone 2025-07-10 01:27:29 +02:00
parent 0160bf1547
commit 7dd3523044
2 changed files with 2 additions and 2 deletions

View File

@ -189,6 +189,6 @@ cast! {
v: char => Self::new(v), v: char => Self::new(v),
v: Content => match v.to_packed::<SymbolElem>() { v: Content => match v.to_packed::<SymbolElem>() {
Some(elem) if elem.text.chars().count() == 1 => Self::new(elem.text.chars().next().unwrap()), Some(elem) if elem.text.chars().count() == 1 => Self::new(elem.text.chars().next().unwrap()),
_ => bail!("expected a single-character symbol"), _ => bail!("expected a single-codepoint symbol"),
}, },
} }

View File

@ -274,7 +274,7 @@ cast! {
Delimiter, Delimiter,
self => self.0.into_value(), self => self.0.into_value(),
_: NoneValue => Self::none(), _: NoneValue => Self::none(),
v: Symbol => Self::char(v.get().parse::<char>().map_err(|_| "symbol value is longer than one character")?)?, v: Symbol => Self::char(v.get().parse::<char>().map_err(|_| "expected a single-codepoint symbol")?)?,
v: char => Self::char(v)?, v: char => Self::char(v)?,
} }