summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lib.rs12
1 files changed, 11 insertions, 1 deletions
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<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
{