cleanups in roc_std

This commit is contained in:
Folkert 2023-11-18 22:42:33 +01:00
parent 88575b2140
commit 6d55acc5cf
No known key found for this signature in database
GPG Key ID: 1F17F6FFD112B97C
3 changed files with 7 additions and 8 deletions

View File

@ -494,7 +494,7 @@ impl PartialEq for I128 {
impl PartialOrd for I128 {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
i128::from(*self).partial_cmp(&i128::from(*other))
Some(self.cmp(other))
}
}
@ -546,7 +546,7 @@ impl PartialEq for U128 {
impl PartialOrd for U128 {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
u128::from(*self).partial_cmp(&u128::from(*other))
Some(self.cmp(other))
}
}

View File

@ -48,7 +48,7 @@ impl<T> RocBox<T> {
///
/// The box must be unique in order to leak it safely
pub unsafe fn leak(self) -> *mut T {
let ptr = self.contents.as_ptr() as *mut T;
let ptr = self.contents.as_ptr();
core::mem::forget(self);
ptr
}
@ -59,7 +59,7 @@ impl<T> RocBox<T> {
}
pub fn into_inner(self) -> T {
unsafe { ptr::read(self.contents.as_ptr() as *mut T) }
unsafe { ptr::read(self.contents.as_ptr()) }
}
fn storage(&self) -> &Cell<Storage> {

View File

@ -304,7 +304,6 @@ impl RocStr {
// The backing list was not unique, so we can't mutate it in-place.
// ask for `len + 1` to store the original string and the terminator
with_stack_bytes(len + 1, |alloc_ptr: *mut u8| {
let alloc_ptr = alloc_ptr as *mut u8;
let elem_ptr = roc_list.ptr_to_first_elem() as *mut u8;
// memcpy the bytes into the stack allocation
@ -331,7 +330,7 @@ impl RocStr {
// Even if the small string is at capacity, there will be room to write
// a terminator in the byte that's used to store the length.
terminate(bytes.as_mut_ptr() as *mut u8, small_str.len())
terminate(bytes.as_mut_ptr(), small_str.len())
}
}
}
@ -534,7 +533,7 @@ impl RocStr {
// No need to do a heap allocation for an empty string - we
// can just do a stack allocation that will live for the
// duration of the function.
func([terminator].as_mut_ptr() as *mut E, "")
func([terminator].as_mut_ptr(), "")
}
}
}
@ -620,7 +619,7 @@ impl Eq for RocStr {}
impl PartialOrd for RocStr {
fn partial_cmp(&self, other: &Self) -> Option<cmp::Ordering> {
self.as_str().partial_cmp(other.as_str())
Some(self.cmp(other))
}
}