summaryrefslogtreecommitdiff
path: root/crates/typst-library/src/foundations
diff options
context:
space:
mode:
authorPgBiel <9021226+PgBiel@users.noreply.github.com>2025-06-10 11:41:16 -0300
committerGitHub <noreply@github.com>2025-06-10 14:41:16 +0000
commit7c7b962b98a09c1baabdd03ff4ccad8f6d817b37 (patch)
treec44c9b82e3c7ec7bf8feb44cedeae9fa71a107cb /crates/typst-library/src/foundations
parenta18ca3481da17a4de1cc7f9890f0c61efb480655 (diff)
Table multiple headers and subheaders (#6168)
Diffstat (limited to 'crates/typst-library/src/foundations')
-rw-r--r--crates/typst-library/src/foundations/int.rs17
1 files changed, 16 insertions, 1 deletions
diff --git a/crates/typst-library/src/foundations/int.rs b/crates/typst-library/src/foundations/int.rs
index 83a89bf8..f65641ff 100644
--- a/crates/typst-library/src/foundations/int.rs
+++ b/crates/typst-library/src/foundations/int.rs
@@ -1,4 +1,6 @@
-use std::num::{NonZeroI64, NonZeroIsize, NonZeroU64, NonZeroUsize, ParseIntError};
+use std::num::{
+ NonZeroI64, NonZeroIsize, NonZeroU32, NonZeroU64, NonZeroUsize, ParseIntError,
+};
use ecow::{eco_format, EcoString};
use smallvec::SmallVec;
@@ -482,3 +484,16 @@ cast! {
"number too large"
})?,
}
+
+cast! {
+ NonZeroU32,
+ self => Value::Int(self.get() as _),
+ v: i64 => v
+ .try_into()
+ .and_then(|v: u32| v.try_into())
+ .map_err(|_| if v <= 0 {
+ "number must be positive"
+ } else {
+ "number too large"
+ })?,
+}