Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ keywords = ["game", "engine", "gamedev", "graphics", "bevy"]
license = "MIT OR Apache-2.0"
repository = "https://github.com/bevyengine/bevy"
documentation = "https://docs.rs/bevy"
rust-version = "1.88.0"
rust-version = "1.89.0"

[workspace]
resolver = "2"
Expand Down
14 changes: 9 additions & 5 deletions crates/bevy_ptr/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1103,13 +1103,17 @@ impl<'a, T> From<&'a [T]> for ThinSlicePtr<'a, T> {
}

/// Creates a dangling pointer with specified alignment.
/// See [`NonNull::dangling`].
///
/// This is an untyped version of [`NonNull::dangling()`]. The returned pointer has no
/// [provenance](https://doc.rust-lang.org/stable/std/ptr/index.html#provenance).
///
/// # Panics
///
/// If `align` is not a power of two (2, 4, 8, 16, etc.).
pub const fn dangling_with_align(align: NonZeroUsize) -> NonNull<u8> {
debug_assert!(align.is_power_of_two(), "Alignment must be power of two.");
// SAFETY: The pointer will not be null, since it was created
// from the address of a `NonZero<usize>`.
// TODO: use https://doc.rust-lang.org/std/ptr/struct.NonNull.html#method.with_addr once stabilized
unsafe { NonNull::new_unchecked(ptr::null_mut::<u8>().wrapping_add(align.get())) }

NonNull::without_provenance(align)
}

mod private {
Expand Down
Loading