Coverage Report

Created: 2026-01-10 06:32

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/rust/registry/src/index.crates.io-1949cf8c6b5b557f/deranged-0.5.5/src/unsafe_wrapper.rs
Line
Count
Source
1
//! Declaration and implementation of `Unsafe`, which ensures all unsafe operations are correctly
2
//! placed in unsafe blocks.
3
4
/// A value that is safe to use, but is unsafe to construct or mutate.
5
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
6
pub(crate) struct Unsafe<T>(T);
7
8
impl<T: core::fmt::Debug> core::fmt::Debug for Unsafe<T> {
9
    #[inline]
10
    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
11
        self.0.fmt(f)
12
    }
13
}
14
15
impl<T> Unsafe<T> {
16
    /// Create a new `Unsafe`, asserting that all invariants are upheld.
17
    #[inline(always)]
18
416k
    pub(crate) const unsafe fn new(value: T) -> Self {
19
416k
        Self(value)
20
416k
    }
<deranged::unsafe_wrapper::Unsafe<i32>>::new
Line
Count
Source
18
83.3k
    pub(crate) const unsafe fn new(value: T) -> Self {
19
83.3k
        Self(value)
20
83.3k
    }
<deranged::unsafe_wrapper::Unsafe<u8>>::new
Line
Count
Source
18
249k
    pub(crate) const unsafe fn new(value: T) -> Self {
19
249k
        Self(value)
20
249k
    }
<deranged::unsafe_wrapper::Unsafe<u32>>::new
Line
Count
Source
18
83.3k
    pub(crate) const unsafe fn new(value: T) -> Self {
19
83.3k
        Self(value)
20
83.3k
    }
Unexecuted instantiation: <deranged::unsafe_wrapper::Unsafe<i32>>::new
21
22
    /// Get a reference to the inner value.
23
    #[inline(always)]
24
1.74M
    pub(crate) const fn get(&self) -> &T {
25
1.74M
        &self.0
26
1.74M
    }
Unexecuted instantiation: <deranged::unsafe_wrapper::Unsafe<i32>>::get
<deranged::unsafe_wrapper::Unsafe<u8>>::get
Line
Count
Source
24
1.49M
    pub(crate) const fn get(&self) -> &T {
25
1.49M
        &self.0
26
1.49M
    }
<deranged::unsafe_wrapper::Unsafe<u32>>::get
Line
Count
Source
24
249k
    pub(crate) const fn get(&self) -> &T {
25
249k
        &self.0
26
249k
    }
Unexecuted instantiation: <deranged::unsafe_wrapper::Unsafe<i32>>::get
27
}
28
29
impl<T> core::ops::Deref for Unsafe<T> {
30
    type Target = T;
31
32
    #[inline(always)]
33
    fn deref(&self) -> &Self::Target {
34
        &self.0
35
    }
36
}