@@ -17,6 +17,7 @@ pub const fn with_meta_const<T: ?Sized, U: ?Sized>(ptr: *const T, meta: *const U
1717
1818/// Alternative to [`Layout::padding_needed_for`], because it's unstable.
1919#[ must_use]
20+ #[ inline]
2021pub const fn pad_layout_for ( layout : Layout , align : usize ) -> usize {
2122 if !align. is_power_of_two ( ) {
2223 return usize:: MAX ;
@@ -30,6 +31,7 @@ pub const fn pad_layout_for(layout: Layout, align: usize) -> usize {
3031///
3132/// This is equivalent to adding the result of [`pad_layout_for`] to the layout's current size.
3233#[ must_use]
34+ #[ inline]
3335pub const fn pad_layout_to_align ( layout : Layout , align : usize ) -> Layout {
3436 unsafe {
3537 Layout :: from_size_align_unchecked (
@@ -51,6 +53,7 @@ pub const fn pad_layout_to_align(layout: Layout, align: usize) -> Layout {
5153/// - [`AllocError::InvalidLayout`] if the computed layout is invalid.
5254/// - [`AllocError::Other`]`("arithmetic operation overflowed")` if an arithmetic operation
5355/// overflows.
56+ #[ inline]
5457pub const fn repeat_layout ( layout : Layout , count : usize ) -> Result < ( Layout , usize ) , AllocError > {
5558 let padded = pad_layout_to_align ( layout, layout. align ( ) ) ;
5659 match repeat_layout_packed ( padded, count) {
@@ -71,6 +74,7 @@ pub const fn repeat_layout(layout: Layout, count: usize) -> Result<(Layout, usiz
7174///
7275/// - [`AllocError::InvalidLayout`] if the computed layout is invalid.
7376/// - [`AllocError::ArithmeticOverflow`] if an arithmetic operation overflows.
77+ #[ inline]
7478pub const fn repeat_layout_packed ( layout : Layout , count : usize ) -> Result < Layout , AllocError > {
7579 if let Some ( size) = { layout. size ( ) . checked_mul ( count) } {
7680 let align = layout. align ( ) ;
@@ -87,6 +91,8 @@ pub const fn repeat_layout_packed(layout: Layout, count: usize) -> Result<Layout
8791 }
8892}
8993
94+ // TODO: unchecked ops
95+ #[ inline]
9096const fn size_rounded_up_to_align ( sz : usize , align : usize ) -> usize {
9197 let sub1 = align - 1 ;
9298 ( sz + sub1) & !sub1
0 commit comments