Add fmt::Pointer impl for bevy_ptr::{Ptr, PtrMut, OwnedPtr} (#6980)

# Objective

- `bevy_ptr::{Ptr, PtrMut, OwnedPtr}` wrap raw pointers and should be printable using pointer formatting.

## Solution

- Add a `core::fmt::Pointer` impl for `Ptr`, `PtrMut` and `OwnedPtr` based on the wrapped `NonNull` pointer.

---

## Changelog

- Added a `core::fmt::Pointer` impl to `Ptr`, `PtrMut` and `OwnedPtr`.

Co-authored-by: MrGunflame <mrgunflame@protonmail.com>
This commit is contained in:
0xc0001a2040 2022-12-20 23:18:13 +00:00
parent 8545580214
commit c38659ddea

View file

@ -2,6 +2,7 @@
#![no_std]
#![warn(missing_docs)]
use core::fmt::{self, Formatter, Pointer};
use core::{
cell::UnsafeCell, marker::PhantomData, mem::ManuallyDrop, num::NonZeroUsize, ptr::NonNull,
};
@ -94,6 +95,13 @@ macro_rules! impl_ptr {
Self(inner, PhantomData)
}
}
impl Pointer for $ptr<'_> {
#[inline]
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
Pointer::fmt(&self.0, f)
}
}
};
}