Skip to content

Commit

Permalink
fix docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Victoronz committed Mar 3, 2025
1 parent 9e7c244 commit 0bcf251
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
8 changes: 7 additions & 1 deletion crates/bevy_ecs/src/entity/index_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,8 @@ impl<V> Slice<V> {
/// # Safety
///
/// `slice` must stem from an [`IndexMap`] using [`EntityHash`].
///
/// [`entity::index_map::Slice`]: `crate::entity::index_map::Slice`
pub const unsafe fn from_slice_unchecked(slice: &map::Slice<Entity, V>) -> &Self {
// SAFETY: Slice is a transparent wrapper around indexmap::map::Slice.
unsafe { &*(ptr::from_ref(slice) as *const Self) }
Expand All @@ -385,6 +387,8 @@ impl<V> Slice<V> {
/// # Safety
///
/// `slice` must stem from an [`IndexMap`] using [`EntityHash`].
///
/// [`entity::index_map::Slice`]: `crate::entity::index_map::Slice`
pub const unsafe fn from_slice_unchecked_mut(slice: &mut map::Slice<Entity, V>) -> &mut Self {
// SAFETY: Slice is a transparent wrapper around indexmap::map::Slice.
unsafe { &mut *(ptr::from_mut(slice) as *mut Self) }
Expand All @@ -395,11 +399,13 @@ impl<V> Slice<V> {
&self.1
}

/// Constructs a boxed [`entity::index_map::Slice>`] from a boxed [`indexmap::map::Slice`] unsafely.
/// Constructs a boxed [`entity::index_map::Slice`] from a boxed [`indexmap::map::Slice`] unsafely.
///
/// # Safety
///
/// `slice` must stem from an [`IndexMap`] using [`EntityHash`].
///
/// [`entity::index_map::Slice`]: `crate::entity::index_map::Slice`
pub unsafe fn from_boxed_slice_unchecked(slice: Box<map::Slice<Entity, V>>) -> Box<Self> {
// SAFETY: Slice is a transparent wrapper around indexmap::map::Slice.
unsafe { Box::from_raw(Box::into_raw(slice) as *mut Self) }
Expand Down
8 changes: 7 additions & 1 deletion crates/bevy_ecs/src/entity/index_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,8 @@ impl Slice {
/// # Safety
///
/// `slice` must stem from an [`IndexSet`] using [`EntityHash`].
///
/// [`entity::index_set::Slice`]: `crate::entity::index_set::Slice`
pub const unsafe fn from_slice_unchecked(slice: &set::Slice<Entity>) -> &Self {
// SAFETY: Slice is a transparent wrapper around indexmap::set::Slice.
unsafe { &*(ptr::from_ref(slice) as *const Self) }
Expand All @@ -285,6 +287,8 @@ impl Slice {
/// # Safety
///
/// `slice` must stem from an [`IndexSet`] using [`EntityHash`].
///
/// [`entity::index_set::Slice`]: `crate::entity::index_set::Slice`
pub const unsafe fn from_slice_unchecked_mut(slice: &mut set::Slice<Entity>) -> &mut Self {
// SAFETY: Slice is a transparent wrapper around indexmap::set::Slice.
unsafe { &mut *(ptr::from_mut(slice) as *mut Self) }
Expand All @@ -295,11 +299,13 @@ impl Slice {
&self.1
}

/// Constructs a boxed [`entity::index_set::Slice>`] from a boxed [`indexmap::set::Slice`] unsafely.
/// Constructs a boxed [`entity::index_set::Slice`] from a boxed [`indexmap::set::Slice`] unsafely.
///
/// # Safety
///
/// `slice` must stem from an [`IndexSet`] using [`EntityHash`].
///
/// [`entity::index_set::Slice`]: `crate::entity::index_set::Slice`
pub unsafe fn from_boxed_slice_unchecked(slice: Box<set::Slice<Entity>>) -> Box<Self> {
// SAFETY: Slice is a transparent wrapper around indexmap::set::Slice.
unsafe { Box::from_raw(Box::into_raw(slice) as *mut Self) }
Expand Down

0 comments on commit 0bcf251

Please sign in to comment.