Skip to content

Commit 57de259

Browse files
committed
make use of nonnull_provenance
1 parent 62d6447 commit 57de259

File tree

3 files changed

+8
-10
lines changed

3 files changed

+8
-10
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "smolbitset"
33
version = "0.1.0"
44
edition = "2024"
5-
rust-version = "1.85.0"
5+
rust-version = "1.89.0"
66

77
[features]
88
default = ["std"]

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ Any larger values dynamically allocate an appropriately sized `u32` slice on the
1414
[docs-badge]: https://img.shields.io/badge/docs-online-5023dd.svg?style=flat-square
1515
[crates.io link]: https://crates.io/crates/smolbitset
1616
[crates.io version]: https://img.shields.io/crates/v/smolbitset.svg?style=flat-square
17-
[rust-version-badge]: https://img.shields.io/badge/rust-1.85.0+-93450a.svg?style=flat-square
18-
[rust-version-link]: https://blog.rust-lang.org/2025/02/20/Rust-1.85.0.html
17+
[rust-version-badge]: https://img.shields.io/badge/rust-1.89.0+-93450a.svg?style=flat-square
18+
[rust-version-link]: https://blog.rust-lang.org/2025/08/07/Rust-1.89.0/

src/lib.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ use {
2626

2727
use core::convert::Infallible;
2828
use core::mem::MaybeUninit;
29-
use core::ptr::{self, NonNull};
29+
use core::num::NonZero;
30+
use core::ptr::NonNull;
3031

3132
/// Returns the index of the most significant bit set to 1 in the given data.
3233
///
@@ -69,10 +70,7 @@ impl SmolBitSet {
6970
#[must_use]
7071
#[inline]
7172
pub const fn new() -> Self {
72-
let ptr = unsafe { NonNull::new_unchecked(ptr::without_provenance_mut(0b1)) };
73-
74-
// #![feature(nonnull_provenance)] -> https://github.com/rust-lang/rust/issues/135243
75-
// let ptr = NonNull::without_provenance(core::num::NonZero::<usize>::MIN);
73+
let ptr = NonNull::without_provenance(core::num::NonZero::<usize>::MIN);
7674

7775
Self { ptr }
7876
}
@@ -190,8 +188,8 @@ impl SmolBitSet {
190188

191189
#[inline]
192190
const unsafe fn write_inline_data_unchecked(&mut self, data: usize) {
193-
self.ptr =
194-
unsafe { NonNull::new_unchecked(ptr::without_provenance_mut((data << 1) | 0b1)) };
191+
let addr = unsafe { NonZero::new_unchecked((data << 1) | 0b1) };
192+
self.ptr = NonNull::without_provenance(addr);
195193
}
196194

197195
#[inline]

0 commit comments

Comments
 (0)