1
0
Fork 0
mirror of https://github.com/azalea-rs/simdnbt.git synced 2025-08-02 07:26:04 +00:00
This commit is contained in:
mat 2025-08-01 14:24:44 -09:30
parent 80997f7f71
commit b399c48ffa
3 changed files with 15 additions and 20 deletions

View file

@ -404,7 +404,7 @@ impl<'a, 'tape> NbtList<'a, 'tape> {
},
})
}
pub fn int_arrays(&self) -> Option<&[RawList<i32>]> {
pub fn int_arrays(&self) -> Option<&[RawList<'_, i32>]> {
let el = self.element();
if el.kind() != TapeTagKind::IntArrayList {
return None;
@ -424,7 +424,7 @@ impl<'a, 'tape> NbtList<'a, 'tape> {
};
Some(slice)
}
pub fn long_arrays(&self) -> Option<&[RawList<i64>]> {
pub fn long_arrays(&self) -> Option<&[RawList<'_, i64>]> {
let el = self.element();
if el.kind() != TapeTagKind::LongArrayList {
return None;
@ -566,7 +566,7 @@ impl<'a, 'tape> NbtListList<'a, 'tape> {
self.iter.clone().last()
}
pub fn is_empty(self) -> bool {
pub fn is_empty(&self) -> bool {
self.approx_len() == 0
}
}
@ -622,7 +622,7 @@ impl<'a: 'tape, 'tape> NbtListListIter<'a, 'tape> {
self.approx_length
}
pub fn is_empty(self) -> bool {
pub fn is_empty(&self) -> bool {
self.approx_len() == 0
}
}
@ -698,7 +698,7 @@ impl<'a, 'tape> NbtCompoundList<'a, 'tape> {
self.iter.clone().last()
}
pub fn is_empty(self) -> bool {
pub fn is_empty(&self) -> bool {
self.approx_len() == 0
}
}
@ -753,7 +753,7 @@ impl<'a: 'tape, 'tape> NbtCompoundListIter<'a, 'tape> {
self.approx_length
}
pub fn is_empty(self) -> bool {
pub fn is_empty(&self) -> bool {
self.approx_len() == 0
}
}

View file

@ -133,14 +133,9 @@ impl<T, A: Allocator> FastVec<T, A> {
self.ptr.cast().as_ptr()
}
pub fn to_vec(self) -> Vec<T> {
let vec = unsafe {
Vec::from_raw_parts(
self.ptr.cast().as_ptr() as *mut T,
self.len(),
self.capacity(),
)
};
pub fn into_vec(self) -> Vec<T> {
let vec =
unsafe { Vec::from_raw_parts(self.ptr.cast().as_ptr(), self.len(), self.capacity()) };
// the allocation was moved so don't drop it
mem::forget(self);
vec
@ -193,7 +188,7 @@ impl<T, A: Allocator> FastVec<T, A> {
cur: ptr.add(len),
end,
ptr: ptr.cast(),
alloc: alloc,
alloc,
}
}
}
@ -256,7 +251,7 @@ impl<T> From<Vec<T>> for FastVec<T> {
}
impl<T> From<FastVec<T>> for Vec<T> {
fn from(fastvec: FastVec<T>) -> Self {
fastvec.to_vec()
fastvec.into_vec()
}
}
@ -279,7 +274,7 @@ impl<T> Drop for FastVecFromVec<'_, T> {
fn drop(&mut self) {
// we intentionally don't drop the fastvec since the allocation is moved into
// the vec
*self.original = unsafe { ManuallyDrop::take(&mut self.fastvec).to_vec() };
*self.original = unsafe { ManuallyDrop::take(&mut self.fastvec).into_vec() };
}
}

View file

@ -81,7 +81,7 @@ impl Mutf8Str {
// we can't implement FromStr on Cow<Mutf8Str>
#[allow(clippy::should_implement_trait)]
#[inline]
pub fn from_str(s: &str) -> Cow<Mutf8Str> {
pub fn from_str(s: &str) -> Cow<'_, Mutf8Str> {
match mutf8::encode(s) {
Cow::Borrowed(slice) => Cow::Borrowed(Mutf8Str::from_slice(slice)),
Cow::Owned(vec) => Cow::Owned(Mutf8String { vec }),
@ -91,7 +91,7 @@ impl Mutf8Str {
/// Try to convert this MUTF-8 string into a UTF-8 string. If the data isn't
/// valid MUTF-8, it'll return an empty string without erroring.
#[inline]
pub fn to_str(&self) -> Cow<str> {
pub fn to_str(&self) -> Cow<'_, str> {
// fast check to skip if none of the bytes have the top bit set.
// note that this allows some valid utf8 but invalid mutf8 through as
// null bytes aren't allowed in mutf8.
@ -107,7 +107,7 @@ impl Mutf8Str {
}
#[inline]
pub fn to_string_lossy(&self) -> Cow<str> {
pub fn to_string_lossy(&self) -> Cow<'_, str> {
mutf8::decode_lossy(&self.slice)
}