mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 06:14:46 +00:00
Monomorphize record literals
This commit is contained in:
parent
074161733e
commit
c883a6b5ac
6 changed files with 171 additions and 341 deletions
|
@ -118,6 +118,18 @@ impl<T> Slice<T> {
|
|||
_marker: PhantomData,
|
||||
}
|
||||
}
|
||||
|
||||
pub const fn truncate(&self, length: u16) -> Self {
|
||||
Self {
|
||||
start: self.start,
|
||||
length,
|
||||
_marker: PhantomData,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn into_nonempty_slice(&self) -> Option<NonEmptySlice<T>> {
|
||||
NonZeroU16::new(self.length).map(|nonzero_len| NonEmptySlice::new(self.start, nonzero_len))
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> IntoIterator for Slice<T> {
|
||||
|
@ -225,6 +237,16 @@ impl<T> NonEmptySlice<T> {
|
|||
pub const unsafe fn from_slice_unchecked(slice: Slice<T>) -> Self {
|
||||
Self::new(slice.start, NonZeroU16::new_unchecked(slice.length))
|
||||
}
|
||||
|
||||
pub const fn truncate(&self, length: NonZeroU16) -> Self {
|
||||
Self {
|
||||
inner: Slice {
|
||||
start: self.inner.start,
|
||||
length: length.get(),
|
||||
_marker: PhantomData,
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> IntoIterator for NonEmptySlice<T> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue