1//! Declaration and implementation of `Unsafe`, which ensures all unsafe operations are correctly
2//! placed in unsafe blocks.
34/// A value that is safe to use, but is unsafe to construct or mutate.
5#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
6pub(crate) struct Unsafe<T>(T);
78impl<T: core::fmt::Debug> core::fmt::Debug for Unsafe<T> {
9#[inline]
10fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
11self.0.fmt(f)
12 }
13}
1415impl<T> Unsafe<T> {
16/// Create a new `Unsafe`, asserting that all invariants are upheld.
17#[inline(always)]
18pub(crate) const unsafe fn new(value: T) -> Self {
19Self(value)
20 }
2122/// Get a reference to the inner value.
23#[inline(always)]
24pub(crate) const fn get(&self) -> &T {
25&self.0
26}
27}
2829impl<T> core::ops::Deref for Unsafe<T> {
30type Target = T;
3132#[inline(always)]
33fn deref(&self) -> &Self::Target {
34&self.0
35}
36}