Skip to content

Commit ab57893

Browse files
committed
inline unstable.rs functions
1 parent 7141e0e commit ab57893

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ _no versions before 0.13.2 have a changelog as I started the changelog in that v
3535

3636
## Version 0.15.0
3737

38+
### Commit 3 (2025-8-05)
39+
40+
- Inline unstable.rs
41+
3842
### Commit 2 (2025-8-05)
3943

4044
- Remove all `#[inline]` statements

src/unstable_util.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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]
2021
pub 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]
3335
pub 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]
5457
pub 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]
7478
pub 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]
9096
const fn size_rounded_up_to_align(sz: usize, align: usize) -> usize {
9197
let sub1 = align - 1;
9298
(sz + sub1) & !sub1

0 commit comments

Comments
 (0)