diff options
| author | Laurenz <laurmaedje@gmail.com> | 2024-10-27 19:04:55 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-10-27 18:04:55 +0000 |
| commit | be7cfc85d08c545abfac08098b7b33b4bd71f37e (patch) | |
| tree | f4137fa2aaa57babae1f7603a9b2ed7e688f43d8 /crates/typst-syntax/src/span.rs | |
| parent | b8034a343831e8609aec2ec81eb7eeda57aa5d81 (diff) | |
Split out four new crates (#5302)
Diffstat (limited to 'crates/typst-syntax/src/span.rs')
| -rw-r--r-- | crates/typst-syntax/src/span.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/crates/typst-syntax/src/span.rs b/crates/typst-syntax/src/span.rs index 85745f60..0847ceea 100644 --- a/crates/typst-syntax/src/span.rs +++ b/crates/typst-syntax/src/span.rs @@ -83,6 +83,20 @@ impl Span { self.0.get() & ((1 << Self::BITS) - 1) } + /// Construct from a raw number. + /// + /// Should only be used with numbers retrieved via + /// [`into_raw`](Self::into_raw). Misuse may results in panics, but no + /// unsafety. + pub const fn from_raw(v: NonZeroU64) -> Self { + Self(v) + } + + /// Extract the raw underlying number. + pub const fn into_raw(self) -> NonZeroU64 { + self.0 + } + /// Return `other` if `self` is detached and `self` otherwise. pub fn or(self, other: Self) -> Self { if self.is_detached() { |
