summaryrefslogtreecommitdiff
path: root/rust/kernel/alloc/layout.rs
diff options
context:
space:
mode:
Diffstat (limited to 'rust/kernel/alloc/layout.rs')
-rw-r--r--rust/kernel/alloc/layout.rs5
1 files changed, 5 insertions, 0 deletions
diff --git a/rust/kernel/alloc/layout.rs b/rust/kernel/alloc/layout.rs
index 93ed514f7cc7..666accb7859c 100644
--- a/rust/kernel/alloc/layout.rs
+++ b/rust/kernel/alloc/layout.rs
@@ -98,6 +98,11 @@ impl<T> ArrayLayout<T> {
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 {