From 5f6da82e31d3e4e0096428899c5b4c67361c1bb3 Mon Sep 17 00:00:00 2001 From: HampusM Date: Tue, 27 Aug 2024 21:11:49 +0200 Subject: refactor: fix clippy lints --- src/lib.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/lib.rs b/src/lib.rs index 2884434..6b1a2e4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -59,6 +59,7 @@ where }; /// Returns a new `MultiVec`. This function does not allocate any memory. + #[must_use] pub const fn new() -> Self { Self { @@ -73,6 +74,7 @@ where /// Returns a new `MultiVec` with a capacity for `capacity` items. This function will /// allocate memory. + #[must_use] pub fn with_capacity(capacity: usize) -> Self { let mut this = Self { @@ -119,6 +121,7 @@ where /// Returns a field of the item with the given index. /// /// This function is equivalant to doing `.get_all().get(index)` + #[must_use] pub fn get( &self, index: usize, @@ -142,6 +145,7 @@ where } /// Returns a slice containing the specified field of all items. + #[must_use] pub fn get_all(&self) -> &[>::Field] where FieldSel: ItemFieldSelection, @@ -154,18 +158,21 @@ where } /// Returns the number of items stored in this `MultiVec`. + #[must_use] pub fn len(&self) -> usize { self.length } /// Returns how many items this `MultiVec` has capacity for. + #[must_use] pub fn capacity(&self) -> usize { self.capacity } /// Returns whether this `MultiVec` is empty. + #[must_use] pub fn is_empty(&self) -> bool { self.length == 0 @@ -275,7 +282,9 @@ where unsafe { std::ptr::copy_nonoverlapping( - (&item as *const ItemT).byte_add(field_metadata.offset) as *const u8, + std::ptr::from_ref(&item) + .byte_add(field_metadata.offset) + .cast::(), field_ptr.as_ptr(), field_metadata.size, ); @@ -473,6 +482,7 @@ const fn array_layout( unsafe { Ok(Layout::from_size_align_unchecked(array_size, align)) } } +#[allow(clippy::inline_always)] #[inline(always)] const fn max_size_for_align(align: usize) -> usize { -- cgit v1.2.3-18-g5258