Rename into_u16 to as_u16

This commit is contained in:
Laurenz 2023-06-06 19:06:56 +02:00
parent f453565ebf
commit 219f14355b
5 changed files with 6 additions and 6 deletions

View File

@ -570,7 +570,7 @@ impl World for SystemWorld {
} }
fn source(&self, id: SourceId) -> &Source { 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> { fn book(&self) -> &Prehashed<FontBook> {

View File

@ -478,7 +478,7 @@ impl World for DocWorld {
} }
fn source(&self, id: SourceId) -> &Source { 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 &self.0
} }

View File

@ -282,7 +282,7 @@ impl SourceId {
} }
/// Extract the underlying number. /// Extract the underlying number.
pub const fn into_u16(self) -> u16 { pub const fn as_u16(self) -> u16 {
self.0 self.0
} }
} }

View File

@ -56,7 +56,7 @@ impl Span {
/// Pack the components into a span. /// Pack the components into a span.
#[track_caller] #[track_caller]
const fn pack(id: SourceId, number: u64) -> Span { 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) { match NonZeroU64::new(bits) {
Some(v) => Self(v), Some(v) => Self(v),
None => panic!("span encoding is zero"), None => panic!("span encoding is zero"),

View File

@ -279,7 +279,7 @@ impl World for TestWorld {
} }
fn source(&self, id: SourceId) -> &Source { 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> { fn book(&self) -> &Prehashed<FontBook> {
@ -307,7 +307,7 @@ impl TestWorld {
let slot = self.slot(path); let slot = self.slot(path);
let id = if let Some(&Ok(id)) = slot.source.get() { let id = if let Some(&Ok(id)) = slot.source.get() {
drop(slot); 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 id
} else { } else {
let id = self.insert(path, text); let id = self.insert(path, text);