diff options
author | HampusM <hampus@hampusmat.com> | 2024-08-27 21:11:49 +0200 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2024-08-27 21:11:49 +0200 |
commit | 5f6da82e31d3e4e0096428899c5b4c67361c1bb3 (patch) | |
tree | ac76b21496256292fa2ad67ed92177ce41069246 /src | |
parent | 895b25dcf214ece8b61d33dfa67bda0da5a5546d (diff) |
Diffstat (limited to 'src')
-rw-r--r-- | src/lib.rs | 12 |
1 files changed, 11 insertions, 1 deletions
@@ -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<FieldSel>( &self, index: usize, @@ -142,6 +145,7 @@ where } /// Returns a slice containing the specified field of all items. + #[must_use] pub fn get_all<FieldSel>(&self) -> &[<FieldSel as ItemFieldSelection<ItemT>>::Field] where FieldSel: ItemFieldSelection<ItemT>, @@ -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::<u8>(), 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 { |