mirror of
https://github.com/typst/typst
synced 2025-05-14 04:56:26 +08:00
Rename into_u16
to as_u16
This commit is contained in:
parent
f453565ebf
commit
219f14355b
@ -570,7 +570,7 @@ impl World for SystemWorld {
|
||||
}
|
||||
|
||||
fn source(&self, id: SourceId) -> &Source {
|
||||
&self.sources[id.into_u16() as usize]
|
||||
&self.sources[id.as_u16() as usize]
|
||||
}
|
||||
|
||||
fn book(&self) -> &Prehashed<FontBook> {
|
||||
|
@ -478,7 +478,7 @@ impl World for DocWorld {
|
||||
}
|
||||
|
||||
fn source(&self, id: SourceId) -> &Source {
|
||||
assert_eq!(id.into_u16(), 0, "invalid source id");
|
||||
assert_eq!(id.as_u16(), 0, "invalid source id");
|
||||
&self.0
|
||||
}
|
||||
|
||||
|
@ -282,7 +282,7 @@ impl SourceId {
|
||||
}
|
||||
|
||||
/// Extract the underlying number.
|
||||
pub const fn into_u16(self) -> u16 {
|
||||
pub const fn as_u16(self) -> u16 {
|
||||
self.0
|
||||
}
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ impl Span {
|
||||
/// Pack the components into a span.
|
||||
#[track_caller]
|
||||
const fn pack(id: SourceId, number: u64) -> Span {
|
||||
let bits = ((id.into_u16() as u64) << Self::BITS) | number;
|
||||
let bits = ((id.as_u16() as u64) << Self::BITS) | number;
|
||||
match NonZeroU64::new(bits) {
|
||||
Some(v) => Self(v),
|
||||
None => panic!("span encoding is zero"),
|
||||
|
@ -279,7 +279,7 @@ impl World for TestWorld {
|
||||
}
|
||||
|
||||
fn source(&self, id: SourceId) -> &Source {
|
||||
&self.sources[id.into_u16() as usize]
|
||||
&self.sources[id.as_u16() as usize]
|
||||
}
|
||||
|
||||
fn book(&self) -> &Prehashed<FontBook> {
|
||||
@ -307,7 +307,7 @@ impl TestWorld {
|
||||
let slot = self.slot(path);
|
||||
let id = if let Some(&Ok(id)) = slot.source.get() {
|
||||
drop(slot);
|
||||
self.sources.as_mut()[id.into_u16() as usize].replace(text);
|
||||
self.sources.as_mut()[id.as_u16() as usize].replace(text);
|
||||
id
|
||||
} else {
|
||||
let id = self.insert(path, text);
|
||||
|
Loading…
x
Reference in New Issue
Block a user