Commit 9acb4e63 authored by Danilo Krummrich's avatar Danilo Krummrich
Browse files

rust: alloc: layout: implement ArrayLayout::size()



Provide a convenience method for ArrayLayout to calculate the size of
the ArrayLayout in bytes.

Reviewed-by: default avatarAlexandre Courbot <acourbot@nvidia.com>
Tested-by: default avatarAlexandre Courbot <acourbot@nvidia.com>
Reviewed-by: default avatarAlice Ryhl <aliceryhl@google.com>
Reviewed-by: default avatarAbdiel Janulgue <abdiel.janulgue@gmail.com>
Link: https://lore.kernel.org/r/20250820145434.94745-7-dakr@kernel.org


Signed-off-by: default avatarDanilo Krummrich <dakr@kernel.org>
parent 67161843
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -98,6 +98,11 @@ pub const fn len(&self) -> usize {
    pub const fn is_empty(&self) -> bool {
        self.len == 0
    }

    /// Returns the size of the [`ArrayLayout`] in bytes.
    pub const fn size(&self) -> usize {
        self.len() * core::mem::size_of::<T>()
    }
}

impl<T> From<ArrayLayout<T>> for Layout {