Coverage Report

Created: 2025-11-16 07:09

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/rust/registry/src/index.crates.io-1949cf8c6b5b557f/anyhow-1.0.100/src/ptr.rs
Line
Count
Source
1
use alloc::boxed::Box;
2
use core::marker::PhantomData;
3
use core::ptr::NonNull;
4
5
#[repr(transparent)]
6
pub struct Own<T>
7
where
8
    T: ?Sized,
9
{
10
    pub ptr: NonNull<T>,
11
}
12
13
unsafe impl<T> Send for Own<T> where T: ?Sized {}
14
15
unsafe impl<T> Sync for Own<T> where T: ?Sized {}
16
17
impl<T> Copy for Own<T> where T: ?Sized {}
18
19
impl<T> Clone for Own<T>
20
where
21
    T: ?Sized,
22
{
23
0
    fn clone(&self) -> Self {
24
0
        *self
25
0
    }
26
}
27
28
impl<T> Own<T>
29
where
30
    T: ?Sized,
31
{
32
14.3k
    pub fn new(ptr: Box<T>) -> Self {
33
14.3k
        Own {
34
14.3k
            ptr: unsafe { NonNull::new_unchecked(Box::into_raw(ptr)) },
35
14.3k
        }
36
14.3k
    }
Unexecuted instantiation: <anyhow::ptr::Own<anyhow::error::ErrorImpl<gix_config::lookup::existing::Error>>>::new
<anyhow::ptr::Own<anyhow::error::ErrorImpl<gix_config::file::init::types::Error>>>::new
Line
Count
Source
32
740
    pub fn new(ptr: Box<T>) -> Self {
33
740
        Own {
34
740
            ptr: unsafe { NonNull::new_unchecked(Box::into_raw(ptr)) },
35
740
        }
36
740
    }
Unexecuted instantiation: <anyhow::ptr::Own<anyhow::error::ErrorImpl<gix_config::parse::section::types::value_name::Error>>>::new
Unexecuted instantiation: <anyhow::ptr::Own<anyhow::error::ErrorImpl<anyhow::wrapper::MessageError<alloc::string::String>>>>::new
Unexecuted instantiation: <anyhow::ptr::Own<anyhow::error::ErrorImpl<anyhow::wrapper::MessageError<&str>>>>::new
Unexecuted instantiation: <anyhow::ptr::Own<anyhow::error::ErrorImpl<anyhow::wrapper::BoxedError>>>::new
<anyhow::ptr::Own<anyhow::error::ErrorImpl<gix_config_value::Error>>>::new
Line
Count
Source
32
2.33k
    pub fn new(ptr: Box<T>) -> Self {
33
2.33k
        Own {
34
2.33k
            ptr: unsafe { NonNull::new_unchecked(Box::into_raw(ptr)) },
35
2.33k
        }
36
2.33k
    }
<anyhow::ptr::Own<anyhow::error::ErrorImpl<gix_validate::reference::name::Error>>>::new
Line
Count
Source
32
875
    pub fn new(ptr: Box<T>) -> Self {
33
875
        Own {
34
875
            ptr: unsafe { NonNull::new_unchecked(Box::into_raw(ptr)) },
35
875
        }
36
875
    }
Unexecuted instantiation: <anyhow::ptr::Own<anyhow::error::ErrorImpl<gix_ref::store_impl::packed::iter::error::Error>>>::new
<anyhow::ptr::Own<anyhow::error::ErrorImpl<gix_ref::store_impl::packed::buffer::open::error::Error>>>::new
Line
Count
Source
32
866
    pub fn new(ptr: Box<T>) -> Self {
33
866
        Own {
34
866
            ptr: unsafe { NonNull::new_unchecked(Box::into_raw(ptr)) },
35
866
        }
36
866
    }
<anyhow::ptr::Own<anyhow::error::ErrorImpl<gix_validate::reference::name::Error>>>::new
Line
Count
Source
32
1.78k
    pub fn new(ptr: Box<T>) -> Self {
33
1.78k
        Own {
34
1.78k
            ptr: unsafe { NonNull::new_unchecked(Box::into_raw(ptr)) },
35
1.78k
        }
36
1.78k
    }
Unexecuted instantiation: <anyhow::ptr::Own<anyhow::error::ErrorImpl<std::io::error::Error>>>::new
<anyhow::ptr::Own<anyhow::error::ErrorImpl<gix_ref::store_impl::file::log::line::decode::error::Error>>>::new
Line
Count
Source
32
865
    pub fn new(ptr: Box<T>) -> Self {
33
865
        Own {
34
865
            ptr: unsafe { NonNull::new_unchecked(Box::into_raw(ptr)) },
35
865
        }
36
865
    }
<anyhow::ptr::Own<anyhow::error::ErrorImpl<gix_commitgraph::file::init::Error>>>::new
Line
Count
Source
32
934
    pub fn new(ptr: Box<T>) -> Self {
33
934
        Own {
34
934
            ptr: unsafe { NonNull::new_unchecked(Box::into_raw(ptr)) },
35
934
        }
36
934
    }
Unexecuted instantiation: <anyhow::ptr::Own<anyhow::error::ErrorImpl<std::io::error::Error>>>::new
<anyhow::ptr::Own<anyhow::error::ErrorImpl<gix_url::parse::Error>>>::new
Line
Count
Source
32
4.41k
    pub fn new(ptr: Box<T>) -> Self {
33
4.41k
        Own {
34
4.41k
            ptr: unsafe { NonNull::new_unchecked(Box::into_raw(ptr)) },
35
4.41k
        }
36
4.41k
    }
<anyhow::ptr::Own<anyhow::error::ErrorImpl<gix_pathspec::parse::Error>>>::new
Line
Count
Source
32
1.52k
    pub fn new(ptr: Box<T>) -> Self {
33
1.52k
        Own {
34
1.52k
            ptr: unsafe { NonNull::new_unchecked(Box::into_raw(ptr)) },
35
1.52k
        }
36
1.52k
    }
37
38
28.6k
    pub fn cast<U: CastTo>(self) -> Own<U::Target> {
39
28.6k
        Own {
40
28.6k
            ptr: self.ptr.cast(),
41
28.6k
        }
42
28.6k
    }
Unexecuted instantiation: <anyhow::ptr::Own<anyhow::error::ErrorImpl<gix_config::lookup::existing::Error>>>::cast::<anyhow::error::ErrorImpl>
<anyhow::ptr::Own<anyhow::error::ErrorImpl<gix_config::file::init::types::Error>>>::cast::<anyhow::error::ErrorImpl>
Line
Count
Source
38
740
    pub fn cast<U: CastTo>(self) -> Own<U::Target> {
39
740
        Own {
40
740
            ptr: self.ptr.cast(),
41
740
        }
42
740
    }
Unexecuted instantiation: <anyhow::ptr::Own<anyhow::error::ErrorImpl<gix_config::parse::section::types::value_name::Error>>>::cast::<anyhow::error::ErrorImpl>
Unexecuted instantiation: <anyhow::ptr::Own<anyhow::error::ErrorImpl>>::cast::<anyhow::error::ErrorImpl<core::mem::manually_drop::ManuallyDrop<gix_config::lookup::existing::Error>>>
Unexecuted instantiation: <anyhow::ptr::Own<anyhow::error::ErrorImpl>>::cast::<anyhow::error::ErrorImpl<core::mem::manually_drop::ManuallyDrop<gix_config::file::init::types::Error>>>
Unexecuted instantiation: <anyhow::ptr::Own<anyhow::error::ErrorImpl>>::cast::<anyhow::error::ErrorImpl<core::mem::manually_drop::ManuallyDrop<gix_config::parse::section::types::value_name::Error>>>
Unexecuted instantiation: <anyhow::ptr::Own<anyhow::error::ErrorImpl>>::cast::<anyhow::error::ErrorImpl<gix_config::lookup::existing::Error>>
<anyhow::ptr::Own<anyhow::error::ErrorImpl>>::cast::<anyhow::error::ErrorImpl<gix_config::file::init::types::Error>>
Line
Count
Source
38
740
    pub fn cast<U: CastTo>(self) -> Own<U::Target> {
39
740
        Own {
40
740
            ptr: self.ptr.cast(),
41
740
        }
42
740
    }
Unexecuted instantiation: <anyhow::ptr::Own<anyhow::error::ErrorImpl>>::cast::<anyhow::error::ErrorImpl<gix_config::parse::section::types::value_name::Error>>
Unexecuted instantiation: <anyhow::ptr::Own<anyhow::error::ErrorImpl<anyhow::wrapper::MessageError<alloc::string::String>>>>::cast::<anyhow::error::ErrorImpl>
Unexecuted instantiation: <anyhow::ptr::Own<anyhow::error::ErrorImpl<anyhow::wrapper::MessageError<&str>>>>::cast::<anyhow::error::ErrorImpl>
Unexecuted instantiation: <anyhow::ptr::Own<anyhow::error::ErrorImpl<anyhow::wrapper::BoxedError>>>::cast::<anyhow::error::ErrorImpl>
Unexecuted instantiation: <anyhow::ptr::Own<anyhow::error::ErrorImpl>>::cast::<anyhow::error::ErrorImpl<anyhow::wrapper::MessageError<alloc::string::String>>>
Unexecuted instantiation: <anyhow::ptr::Own<anyhow::error::ErrorImpl>>::cast::<anyhow::error::ErrorImpl<anyhow::wrapper::MessageError<&str>>>
Unexecuted instantiation: <anyhow::ptr::Own<anyhow::error::ErrorImpl>>::cast::<anyhow::error::ErrorImpl<core::mem::manually_drop::ManuallyDrop<alloc::boxed::Box<dyn core::error::Error + core::marker::Sync + core::marker::Send>>>>
Unexecuted instantiation: <anyhow::ptr::Own<anyhow::error::ErrorImpl>>::cast::<anyhow::error::ErrorImpl<core::mem::manually_drop::ManuallyDrop<alloc::string::String>>>
Unexecuted instantiation: <anyhow::ptr::Own<anyhow::error::ErrorImpl>>::cast::<anyhow::error::ErrorImpl<core::mem::manually_drop::ManuallyDrop<&str>>>
Unexecuted instantiation: <anyhow::ptr::Own<anyhow::error::ErrorImpl>>::cast::<anyhow::error::ErrorImpl<anyhow::wrapper::BoxedError>>
<anyhow::ptr::Own<anyhow::error::ErrorImpl<gix_config_value::Error>>>::cast::<anyhow::error::ErrorImpl>
Line
Count
Source
38
2.33k
    pub fn cast<U: CastTo>(self) -> Own<U::Target> {
39
2.33k
        Own {
40
2.33k
            ptr: self.ptr.cast(),
41
2.33k
        }
42
2.33k
    }
Unexecuted instantiation: <anyhow::ptr::Own<anyhow::error::ErrorImpl>>::cast::<anyhow::error::ErrorImpl<core::mem::manually_drop::ManuallyDrop<gix_config_value::Error>>>
<anyhow::ptr::Own<anyhow::error::ErrorImpl>>::cast::<anyhow::error::ErrorImpl<gix_config_value::Error>>
Line
Count
Source
38
2.33k
    pub fn cast<U: CastTo>(self) -> Own<U::Target> {
39
2.33k
        Own {
40
2.33k
            ptr: self.ptr.cast(),
41
2.33k
        }
42
2.33k
    }
<anyhow::ptr::Own<anyhow::error::ErrorImpl<gix_validate::reference::name::Error>>>::cast::<anyhow::error::ErrorImpl>
Line
Count
Source
38
875
    pub fn cast<U: CastTo>(self) -> Own<U::Target> {
39
875
        Own {
40
875
            ptr: self.ptr.cast(),
41
875
        }
42
875
    }
Unexecuted instantiation: <anyhow::ptr::Own<anyhow::error::ErrorImpl<gix_ref::store_impl::packed::iter::error::Error>>>::cast::<anyhow::error::ErrorImpl>
<anyhow::ptr::Own<anyhow::error::ErrorImpl<gix_ref::store_impl::packed::buffer::open::error::Error>>>::cast::<anyhow::error::ErrorImpl>
Line
Count
Source
38
866
    pub fn cast<U: CastTo>(self) -> Own<U::Target> {
39
866
        Own {
40
866
            ptr: self.ptr.cast(),
41
866
        }
42
866
    }
Unexecuted instantiation: <anyhow::ptr::Own<anyhow::error::ErrorImpl>>::cast::<anyhow::error::ErrorImpl<core::mem::manually_drop::ManuallyDrop<gix_validate::reference::name::Error>>>
Unexecuted instantiation: <anyhow::ptr::Own<anyhow::error::ErrorImpl>>::cast::<anyhow::error::ErrorImpl<core::mem::manually_drop::ManuallyDrop<gix_ref::store_impl::packed::iter::error::Error>>>
Unexecuted instantiation: <anyhow::ptr::Own<anyhow::error::ErrorImpl>>::cast::<anyhow::error::ErrorImpl<core::mem::manually_drop::ManuallyDrop<gix_ref::store_impl::packed::buffer::open::error::Error>>>
<anyhow::ptr::Own<anyhow::error::ErrorImpl>>::cast::<anyhow::error::ErrorImpl<gix_validate::reference::name::Error>>
Line
Count
Source
38
875
    pub fn cast<U: CastTo>(self) -> Own<U::Target> {
39
875
        Own {
40
875
            ptr: self.ptr.cast(),
41
875
        }
42
875
    }
Unexecuted instantiation: <anyhow::ptr::Own<anyhow::error::ErrorImpl>>::cast::<anyhow::error::ErrorImpl<gix_ref::store_impl::packed::iter::error::Error>>
<anyhow::ptr::Own<anyhow::error::ErrorImpl>>::cast::<anyhow::error::ErrorImpl<gix_ref::store_impl::packed::buffer::open::error::Error>>
Line
Count
Source
38
866
    pub fn cast<U: CastTo>(self) -> Own<U::Target> {
39
866
        Own {
40
866
            ptr: self.ptr.cast(),
41
866
        }
42
866
    }
<anyhow::ptr::Own<anyhow::error::ErrorImpl<gix_validate::reference::name::Error>>>::cast::<anyhow::error::ErrorImpl>
Line
Count
Source
38
1.78k
    pub fn cast<U: CastTo>(self) -> Own<U::Target> {
39
1.78k
        Own {
40
1.78k
            ptr: self.ptr.cast(),
41
1.78k
        }
42
1.78k
    }
Unexecuted instantiation: <anyhow::ptr::Own<anyhow::error::ErrorImpl>>::cast::<anyhow::error::ErrorImpl<core::mem::manually_drop::ManuallyDrop<gix_validate::reference::name::Error>>>
<anyhow::ptr::Own<anyhow::error::ErrorImpl>>::cast::<anyhow::error::ErrorImpl<gix_validate::reference::name::Error>>
Line
Count
Source
38
1.78k
    pub fn cast<U: CastTo>(self) -> Own<U::Target> {
39
1.78k
        Own {
40
1.78k
            ptr: self.ptr.cast(),
41
1.78k
        }
42
1.78k
    }
Unexecuted instantiation: <anyhow::ptr::Own<anyhow::error::ErrorImpl<std::io::error::Error>>>::cast::<anyhow::error::ErrorImpl>
<anyhow::ptr::Own<anyhow::error::ErrorImpl<gix_ref::store_impl::file::log::line::decode::error::Error>>>::cast::<anyhow::error::ErrorImpl>
Line
Count
Source
38
865
    pub fn cast<U: CastTo>(self) -> Own<U::Target> {
39
865
        Own {
40
865
            ptr: self.ptr.cast(),
41
865
        }
42
865
    }
Unexecuted instantiation: <anyhow::ptr::Own<anyhow::error::ErrorImpl>>::cast::<anyhow::error::ErrorImpl<core::mem::manually_drop::ManuallyDrop<std::io::error::Error>>>
Unexecuted instantiation: <anyhow::ptr::Own<anyhow::error::ErrorImpl>>::cast::<anyhow::error::ErrorImpl<core::mem::manually_drop::ManuallyDrop<gix_ref::store_impl::file::log::line::decode::error::Error>>>
Unexecuted instantiation: <anyhow::ptr::Own<anyhow::error::ErrorImpl>>::cast::<anyhow::error::ErrorImpl<std::io::error::Error>>
<anyhow::ptr::Own<anyhow::error::ErrorImpl>>::cast::<anyhow::error::ErrorImpl<gix_ref::store_impl::file::log::line::decode::error::Error>>
Line
Count
Source
38
865
    pub fn cast<U: CastTo>(self) -> Own<U::Target> {
39
865
        Own {
40
865
            ptr: self.ptr.cast(),
41
865
        }
42
865
    }
<anyhow::ptr::Own<anyhow::error::ErrorImpl<gix_commitgraph::file::init::Error>>>::cast::<anyhow::error::ErrorImpl>
Line
Count
Source
38
934
    pub fn cast<U: CastTo>(self) -> Own<U::Target> {
39
934
        Own {
40
934
            ptr: self.ptr.cast(),
41
934
        }
42
934
    }
Unexecuted instantiation: <anyhow::ptr::Own<anyhow::error::ErrorImpl<std::io::error::Error>>>::cast::<anyhow::error::ErrorImpl>
Unexecuted instantiation: <anyhow::ptr::Own<anyhow::error::ErrorImpl>>::cast::<anyhow::error::ErrorImpl<core::mem::manually_drop::ManuallyDrop<gix_commitgraph::file::init::Error>>>
Unexecuted instantiation: <anyhow::ptr::Own<anyhow::error::ErrorImpl>>::cast::<anyhow::error::ErrorImpl<core::mem::manually_drop::ManuallyDrop<std::io::error::Error>>>
<anyhow::ptr::Own<anyhow::error::ErrorImpl>>::cast::<anyhow::error::ErrorImpl<gix_commitgraph::file::init::Error>>
Line
Count
Source
38
934
    pub fn cast<U: CastTo>(self) -> Own<U::Target> {
39
934
        Own {
40
934
            ptr: self.ptr.cast(),
41
934
        }
42
934
    }
Unexecuted instantiation: <anyhow::ptr::Own<anyhow::error::ErrorImpl>>::cast::<anyhow::error::ErrorImpl<std::io::error::Error>>
<anyhow::ptr::Own<anyhow::error::ErrorImpl<gix_url::parse::Error>>>::cast::<anyhow::error::ErrorImpl>
Line
Count
Source
38
4.41k
    pub fn cast<U: CastTo>(self) -> Own<U::Target> {
39
4.41k
        Own {
40
4.41k
            ptr: self.ptr.cast(),
41
4.41k
        }
42
4.41k
    }
Unexecuted instantiation: <anyhow::ptr::Own<anyhow::error::ErrorImpl>>::cast::<anyhow::error::ErrorImpl<core::mem::manually_drop::ManuallyDrop<gix_url::parse::Error>>>
<anyhow::ptr::Own<anyhow::error::ErrorImpl>>::cast::<anyhow::error::ErrorImpl<gix_url::parse::Error>>
Line
Count
Source
38
4.41k
    pub fn cast<U: CastTo>(self) -> Own<U::Target> {
39
4.41k
        Own {
40
4.41k
            ptr: self.ptr.cast(),
41
4.41k
        }
42
4.41k
    }
<anyhow::ptr::Own<anyhow::error::ErrorImpl<gix_pathspec::parse::Error>>>::cast::<anyhow::error::ErrorImpl>
Line
Count
Source
38
1.52k
    pub fn cast<U: CastTo>(self) -> Own<U::Target> {
39
1.52k
        Own {
40
1.52k
            ptr: self.ptr.cast(),
41
1.52k
        }
42
1.52k
    }
Unexecuted instantiation: <anyhow::ptr::Own<anyhow::error::ErrorImpl>>::cast::<anyhow::error::ErrorImpl<core::mem::manually_drop::ManuallyDrop<gix_pathspec::parse::Error>>>
<anyhow::ptr::Own<anyhow::error::ErrorImpl>>::cast::<anyhow::error::ErrorImpl<gix_pathspec::parse::Error>>
Line
Count
Source
38
1.52k
    pub fn cast<U: CastTo>(self) -> Own<U::Target> {
39
1.52k
        Own {
40
1.52k
            ptr: self.ptr.cast(),
41
1.52k
        }
42
1.52k
    }
43
44
14.3k
    pub unsafe fn boxed(self) -> Box<T> {
45
14.3k
        unsafe { Box::from_raw(self.ptr.as_ptr()) }
46
14.3k
    }
Unexecuted instantiation: <anyhow::ptr::Own<anyhow::error::ErrorImpl<core::mem::manually_drop::ManuallyDrop<gix_config::lookup::existing::Error>>>>::boxed
Unexecuted instantiation: <anyhow::ptr::Own<anyhow::error::ErrorImpl<core::mem::manually_drop::ManuallyDrop<gix_config::file::init::types::Error>>>>::boxed
Unexecuted instantiation: <anyhow::ptr::Own<anyhow::error::ErrorImpl<core::mem::manually_drop::ManuallyDrop<gix_config::parse::section::types::value_name::Error>>>>::boxed
Unexecuted instantiation: <anyhow::ptr::Own<anyhow::error::ErrorImpl<gix_config::lookup::existing::Error>>>::boxed
<anyhow::ptr::Own<anyhow::error::ErrorImpl<gix_config::file::init::types::Error>>>::boxed
Line
Count
Source
44
740
    pub unsafe fn boxed(self) -> Box<T> {
45
740
        unsafe { Box::from_raw(self.ptr.as_ptr()) }
46
740
    }
Unexecuted instantiation: <anyhow::ptr::Own<anyhow::error::ErrorImpl<gix_config::parse::section::types::value_name::Error>>>::boxed
Unexecuted instantiation: <anyhow::ptr::Own<anyhow::error::ErrorImpl<anyhow::wrapper::MessageError<alloc::string::String>>>>::boxed
Unexecuted instantiation: <anyhow::ptr::Own<anyhow::error::ErrorImpl<anyhow::wrapper::MessageError<&str>>>>::boxed
Unexecuted instantiation: <anyhow::ptr::Own<anyhow::error::ErrorImpl<core::mem::manually_drop::ManuallyDrop<alloc::boxed::Box<dyn core::error::Error + core::marker::Sync + core::marker::Send>>>>>::boxed
Unexecuted instantiation: <anyhow::ptr::Own<anyhow::error::ErrorImpl<core::mem::manually_drop::ManuallyDrop<alloc::string::String>>>>::boxed
Unexecuted instantiation: <anyhow::ptr::Own<anyhow::error::ErrorImpl<core::mem::manually_drop::ManuallyDrop<&str>>>>::boxed
Unexecuted instantiation: <anyhow::ptr::Own<anyhow::error::ErrorImpl<anyhow::wrapper::BoxedError>>>::boxed
Unexecuted instantiation: <anyhow::ptr::Own<anyhow::error::ErrorImpl<core::mem::manually_drop::ManuallyDrop<gix_config_value::Error>>>>::boxed
<anyhow::ptr::Own<anyhow::error::ErrorImpl<gix_config_value::Error>>>::boxed
Line
Count
Source
44
2.33k
    pub unsafe fn boxed(self) -> Box<T> {
45
2.33k
        unsafe { Box::from_raw(self.ptr.as_ptr()) }
46
2.33k
    }
Unexecuted instantiation: <anyhow::ptr::Own<anyhow::error::ErrorImpl<core::mem::manually_drop::ManuallyDrop<gix_validate::reference::name::Error>>>>::boxed
Unexecuted instantiation: <anyhow::ptr::Own<anyhow::error::ErrorImpl<core::mem::manually_drop::ManuallyDrop<gix_ref::store_impl::packed::iter::error::Error>>>>::boxed
Unexecuted instantiation: <anyhow::ptr::Own<anyhow::error::ErrorImpl<core::mem::manually_drop::ManuallyDrop<gix_ref::store_impl::packed::buffer::open::error::Error>>>>::boxed
<anyhow::ptr::Own<anyhow::error::ErrorImpl<gix_validate::reference::name::Error>>>::boxed
Line
Count
Source
44
875
    pub unsafe fn boxed(self) -> Box<T> {
45
875
        unsafe { Box::from_raw(self.ptr.as_ptr()) }
46
875
    }
Unexecuted instantiation: <anyhow::ptr::Own<anyhow::error::ErrorImpl<gix_ref::store_impl::packed::iter::error::Error>>>::boxed
<anyhow::ptr::Own<anyhow::error::ErrorImpl<gix_ref::store_impl::packed::buffer::open::error::Error>>>::boxed
Line
Count
Source
44
866
    pub unsafe fn boxed(self) -> Box<T> {
45
866
        unsafe { Box::from_raw(self.ptr.as_ptr()) }
46
866
    }
Unexecuted instantiation: <anyhow::ptr::Own<anyhow::error::ErrorImpl<core::mem::manually_drop::ManuallyDrop<gix_validate::reference::name::Error>>>>::boxed
<anyhow::ptr::Own<anyhow::error::ErrorImpl<gix_validate::reference::name::Error>>>::boxed
Line
Count
Source
44
1.78k
    pub unsafe fn boxed(self) -> Box<T> {
45
1.78k
        unsafe { Box::from_raw(self.ptr.as_ptr()) }
46
1.78k
    }
Unexecuted instantiation: <anyhow::ptr::Own<anyhow::error::ErrorImpl<core::mem::manually_drop::ManuallyDrop<std::io::error::Error>>>>::boxed
Unexecuted instantiation: <anyhow::ptr::Own<anyhow::error::ErrorImpl<core::mem::manually_drop::ManuallyDrop<gix_ref::store_impl::file::log::line::decode::error::Error>>>>::boxed
Unexecuted instantiation: <anyhow::ptr::Own<anyhow::error::ErrorImpl<std::io::error::Error>>>::boxed
<anyhow::ptr::Own<anyhow::error::ErrorImpl<gix_ref::store_impl::file::log::line::decode::error::Error>>>::boxed
Line
Count
Source
44
865
    pub unsafe fn boxed(self) -> Box<T> {
45
865
        unsafe { Box::from_raw(self.ptr.as_ptr()) }
46
865
    }
Unexecuted instantiation: <anyhow::ptr::Own<anyhow::error::ErrorImpl<core::mem::manually_drop::ManuallyDrop<gix_commitgraph::file::init::Error>>>>::boxed
Unexecuted instantiation: <anyhow::ptr::Own<anyhow::error::ErrorImpl<core::mem::manually_drop::ManuallyDrop<std::io::error::Error>>>>::boxed
<anyhow::ptr::Own<anyhow::error::ErrorImpl<gix_commitgraph::file::init::Error>>>::boxed
Line
Count
Source
44
934
    pub unsafe fn boxed(self) -> Box<T> {
45
934
        unsafe { Box::from_raw(self.ptr.as_ptr()) }
46
934
    }
Unexecuted instantiation: <anyhow::ptr::Own<anyhow::error::ErrorImpl<std::io::error::Error>>>::boxed
Unexecuted instantiation: <anyhow::ptr::Own<anyhow::error::ErrorImpl<core::mem::manually_drop::ManuallyDrop<gix_url::parse::Error>>>>::boxed
<anyhow::ptr::Own<anyhow::error::ErrorImpl<gix_url::parse::Error>>>::boxed
Line
Count
Source
44
4.41k
    pub unsafe fn boxed(self) -> Box<T> {
45
4.41k
        unsafe { Box::from_raw(self.ptr.as_ptr()) }
46
4.41k
    }
Unexecuted instantiation: <anyhow::ptr::Own<anyhow::error::ErrorImpl<core::mem::manually_drop::ManuallyDrop<gix_pathspec::parse::Error>>>>::boxed
<anyhow::ptr::Own<anyhow::error::ErrorImpl<gix_pathspec::parse::Error>>>::boxed
Line
Count
Source
44
1.52k
    pub unsafe fn boxed(self) -> Box<T> {
45
1.52k
        unsafe { Box::from_raw(self.ptr.as_ptr()) }
46
1.52k
    }
47
48
4.66k
    pub fn by_ref(&self) -> Ref<T> {
49
4.66k
        Ref {
50
4.66k
            ptr: self.ptr,
51
4.66k
            lifetime: PhantomData,
52
4.66k
        }
53
4.66k
    }
54
55
0
    pub fn by_mut(&mut self) -> Mut<T> {
56
0
        Mut {
57
0
            ptr: self.ptr,
58
0
            lifetime: PhantomData,
59
0
        }
60
0
    }
61
}
62
63
#[repr(transparent)]
64
pub struct Ref<'a, T>
65
where
66
    T: ?Sized,
67
{
68
    pub ptr: NonNull<T>,
69
    lifetime: PhantomData<&'a T>,
70
}
71
72
impl<'a, T> Copy for Ref<'a, T> where T: ?Sized {}
73
74
impl<'a, T> Clone for Ref<'a, T>
75
where
76
    T: ?Sized,
77
{
78
0
    fn clone(&self) -> Self {
79
0
        *self
80
0
    }
81
}
82
83
impl<'a, T> Ref<'a, T>
84
where
85
    T: ?Sized,
86
{
87
0
    pub fn new(ptr: &'a T) -> Self {
88
0
        Ref {
89
0
            ptr: NonNull::from(ptr),
90
0
            lifetime: PhantomData,
91
0
        }
92
0
    }
Unexecuted instantiation: <anyhow::ptr::Ref<anyhow::error::ErrorImpl<gix_config::lookup::existing::Error>>>::new
Unexecuted instantiation: <anyhow::ptr::Ref<anyhow::error::ErrorImpl<gix_config::file::init::types::Error>>>::new
Unexecuted instantiation: <anyhow::ptr::Ref<anyhow::error::ErrorImpl<gix_config::parse::section::types::value_name::Error>>>::new
Unexecuted instantiation: <anyhow::ptr::Ref<anyhow::error::ErrorImpl<anyhow::wrapper::MessageError<alloc::string::String>>>>::new
Unexecuted instantiation: <anyhow::ptr::Ref<anyhow::error::ErrorImpl<anyhow::wrapper::MessageError<&str>>>>::new
Unexecuted instantiation: <anyhow::ptr::Ref<anyhow::error::ErrorImpl<anyhow::wrapper::BoxedError>>>::new
Unexecuted instantiation: <anyhow::ptr::Ref<anyhow::error::ErrorImpl<gix_config_value::Error>>>::new
Unexecuted instantiation: <anyhow::ptr::Ref<anyhow::error::ErrorImpl<gix_validate::reference::name::Error>>>::new
Unexecuted instantiation: <anyhow::ptr::Ref<anyhow::error::ErrorImpl<gix_ref::store_impl::packed::iter::error::Error>>>::new
Unexecuted instantiation: <anyhow::ptr::Ref<anyhow::error::ErrorImpl<gix_ref::store_impl::packed::buffer::open::error::Error>>>::new
Unexecuted instantiation: <anyhow::ptr::Ref<anyhow::error::ErrorImpl<gix_validate::reference::name::Error>>>::new
Unexecuted instantiation: <anyhow::ptr::Ref<anyhow::error::ErrorImpl<std::io::error::Error>>>::new
Unexecuted instantiation: <anyhow::ptr::Ref<anyhow::error::ErrorImpl<gix_ref::store_impl::file::log::line::decode::error::Error>>>::new
Unexecuted instantiation: <anyhow::ptr::Ref<anyhow::error::ErrorImpl<gix_commitgraph::file::init::Error>>>::new
Unexecuted instantiation: <anyhow::ptr::Ref<anyhow::error::ErrorImpl<std::io::error::Error>>>::new
Unexecuted instantiation: <anyhow::ptr::Ref<anyhow::error::ErrorImpl<gix_url::parse::Error>>>::new
Unexecuted instantiation: <anyhow::ptr::Ref<anyhow::error::ErrorImpl<gix_pathspec::parse::Error>>>::new
93
94
    #[cfg(not(anyhow_no_ptr_addr_of))]
95
4.66k
    pub fn from_raw(ptr: NonNull<T>) -> Self {
96
4.66k
        Ref {
97
4.66k
            ptr,
98
4.66k
            lifetime: PhantomData,
99
4.66k
        }
100
4.66k
    }
Unexecuted instantiation: <anyhow::ptr::Ref<dyn core::error::Error + core::marker::Sync + core::marker::Send>>::from_raw
Unexecuted instantiation: <anyhow::ptr::Ref<gix_config::lookup::existing::Error>>::from_raw
Unexecuted instantiation: <anyhow::ptr::Ref<gix_config::file::init::types::Error>>::from_raw
Unexecuted instantiation: <anyhow::ptr::Ref<gix_config::parse::section::types::value_name::Error>>::from_raw
Unexecuted instantiation: <anyhow::ptr::Ref<dyn core::error::Error + core::marker::Sync + core::marker::Send>>::from_raw
Unexecuted instantiation: <anyhow::ptr::Ref<alloc::boxed::Box<dyn core::error::Error + core::marker::Sync + core::marker::Send>>>::from_raw
Unexecuted instantiation: <anyhow::ptr::Ref<alloc::string::String>>::from_raw
Unexecuted instantiation: <anyhow::ptr::Ref<&str>>::from_raw
<anyhow::ptr::Ref<dyn core::error::Error + core::marker::Sync + core::marker::Send>>::from_raw
Line
Count
Source
95
4.66k
    pub fn from_raw(ptr: NonNull<T>) -> Self {
96
4.66k
        Ref {
97
4.66k
            ptr,
98
4.66k
            lifetime: PhantomData,
99
4.66k
        }
100
4.66k
    }
Unexecuted instantiation: <anyhow::ptr::Ref<gix_config_value::Error>>::from_raw
Unexecuted instantiation: <anyhow::ptr::Ref<dyn core::error::Error + core::marker::Sync + core::marker::Send>>::from_raw
Unexecuted instantiation: <anyhow::ptr::Ref<gix_validate::reference::name::Error>>::from_raw
Unexecuted instantiation: <anyhow::ptr::Ref<gix_ref::store_impl::packed::iter::error::Error>>::from_raw
Unexecuted instantiation: <anyhow::ptr::Ref<gix_ref::store_impl::packed::buffer::open::error::Error>>::from_raw
Unexecuted instantiation: <anyhow::ptr::Ref<dyn core::error::Error + core::marker::Sync + core::marker::Send>>::from_raw
Unexecuted instantiation: <anyhow::ptr::Ref<gix_validate::reference::name::Error>>::from_raw
Unexecuted instantiation: <anyhow::ptr::Ref<dyn core::error::Error + core::marker::Sync + core::marker::Send>>::from_raw
Unexecuted instantiation: <anyhow::ptr::Ref<std::io::error::Error>>::from_raw
Unexecuted instantiation: <anyhow::ptr::Ref<gix_ref::store_impl::file::log::line::decode::error::Error>>::from_raw
Unexecuted instantiation: <anyhow::ptr::Ref<dyn core::error::Error + core::marker::Sync + core::marker::Send>>::from_raw
Unexecuted instantiation: <anyhow::ptr::Ref<gix_commitgraph::file::init::Error>>::from_raw
Unexecuted instantiation: <anyhow::ptr::Ref<std::io::error::Error>>::from_raw
Unexecuted instantiation: <anyhow::ptr::Ref<dyn core::error::Error + core::marker::Sync + core::marker::Send>>::from_raw
Unexecuted instantiation: <anyhow::ptr::Ref<gix_url::parse::Error>>::from_raw
Unexecuted instantiation: <anyhow::ptr::Ref<dyn core::error::Error + core::marker::Sync + core::marker::Send>>::from_raw
Unexecuted instantiation: <anyhow::ptr::Ref<gix_pathspec::parse::Error>>::from_raw
101
102
4.66k
    pub fn cast<U: CastTo>(self) -> Ref<'a, U::Target> {
103
4.66k
        Ref {
104
4.66k
            ptr: self.ptr.cast(),
105
4.66k
            lifetime: PhantomData,
106
4.66k
        }
107
4.66k
    }
Unexecuted instantiation: <anyhow::ptr::Ref<anyhow::error::ErrorImpl<gix_config::lookup::existing::Error>>>::cast::<anyhow::error::ErrorImpl>
Unexecuted instantiation: <anyhow::ptr::Ref<anyhow::error::ErrorImpl<gix_config::file::init::types::Error>>>::cast::<anyhow::error::ErrorImpl>
Unexecuted instantiation: <anyhow::ptr::Ref<anyhow::error::ErrorImpl<gix_config::parse::section::types::value_name::Error>>>::cast::<anyhow::error::ErrorImpl>
Unexecuted instantiation: <anyhow::ptr::Ref<anyhow::error::ErrorImpl>>::cast::<anyhow::error::ErrorImpl<gix_config::lookup::existing::Error>>
Unexecuted instantiation: <anyhow::ptr::Ref<anyhow::error::ErrorImpl>>::cast::<anyhow::error::ErrorImpl<gix_config::file::init::types::Error>>
Unexecuted instantiation: <anyhow::ptr::Ref<anyhow::error::ErrorImpl>>::cast::<anyhow::error::ErrorImpl<gix_config::parse::section::types::value_name::Error>>
Unexecuted instantiation: <anyhow::ptr::Ref<gix_config::lookup::existing::Error>>::cast::<()>
Unexecuted instantiation: <anyhow::ptr::Ref<gix_config::file::init::types::Error>>::cast::<()>
Unexecuted instantiation: <anyhow::ptr::Ref<gix_config::parse::section::types::value_name::Error>>::cast::<()>
Unexecuted instantiation: <anyhow::ptr::Ref<anyhow::error::ErrorImpl<anyhow::wrapper::MessageError<alloc::string::String>>>>::cast::<anyhow::error::ErrorImpl>
Unexecuted instantiation: <anyhow::ptr::Ref<anyhow::error::ErrorImpl<anyhow::wrapper::MessageError<&str>>>>::cast::<anyhow::error::ErrorImpl>
Unexecuted instantiation: <anyhow::ptr::Ref<anyhow::error::ErrorImpl<anyhow::wrapper::BoxedError>>>::cast::<anyhow::error::ErrorImpl>
Unexecuted instantiation: <anyhow::ptr::Ref<alloc::boxed::Box<dyn core::error::Error + core::marker::Sync + core::marker::Send>>>::cast::<()>
Unexecuted instantiation: <anyhow::ptr::Ref<anyhow::error::ErrorImpl>>::cast::<anyhow::error::ErrorImpl<anyhow::wrapper::MessageError<alloc::string::String>>>
Unexecuted instantiation: <anyhow::ptr::Ref<anyhow::error::ErrorImpl>>::cast::<anyhow::error::ErrorImpl<anyhow::wrapper::MessageError<&str>>>
Unexecuted instantiation: <anyhow::ptr::Ref<anyhow::error::ErrorImpl>>::cast::<anyhow::error::ErrorImpl<alloc::boxed::Box<dyn core::error::Error + core::marker::Sync + core::marker::Send>>>
Unexecuted instantiation: <anyhow::ptr::Ref<anyhow::error::ErrorImpl>>::cast::<anyhow::error::ErrorImpl<anyhow::wrapper::BoxedError>>
Unexecuted instantiation: <anyhow::ptr::Ref<anyhow::error::ErrorImpl>>::cast::<anyhow::error::ErrorImpl<alloc::string::String>>
Unexecuted instantiation: <anyhow::ptr::Ref<anyhow::error::ErrorImpl>>::cast::<anyhow::error::ErrorImpl<&str>>
Unexecuted instantiation: <anyhow::ptr::Ref<alloc::string::String>>::cast::<()>
Unexecuted instantiation: <anyhow::ptr::Ref<&str>>::cast::<()>
Unexecuted instantiation: <anyhow::ptr::Ref<anyhow::error::ErrorImpl<gix_config_value::Error>>>::cast::<anyhow::error::ErrorImpl>
Unexecuted instantiation: <anyhow::ptr::Ref<gix_config_value::Error>>::cast::<()>
<anyhow::ptr::Ref<anyhow::error::ErrorImpl>>::cast::<anyhow::error::ErrorImpl<gix_config_value::Error>>
Line
Count
Source
102
4.66k
    pub fn cast<U: CastTo>(self) -> Ref<'a, U::Target> {
103
4.66k
        Ref {
104
4.66k
            ptr: self.ptr.cast(),
105
4.66k
            lifetime: PhantomData,
106
4.66k
        }
107
4.66k
    }
Unexecuted instantiation: <anyhow::ptr::Ref<anyhow::error::ErrorImpl<gix_validate::reference::name::Error>>>::cast::<anyhow::error::ErrorImpl>
Unexecuted instantiation: <anyhow::ptr::Ref<anyhow::error::ErrorImpl<gix_ref::store_impl::packed::iter::error::Error>>>::cast::<anyhow::error::ErrorImpl>
Unexecuted instantiation: <anyhow::ptr::Ref<anyhow::error::ErrorImpl<gix_ref::store_impl::packed::buffer::open::error::Error>>>::cast::<anyhow::error::ErrorImpl>
Unexecuted instantiation: <anyhow::ptr::Ref<anyhow::error::ErrorImpl>>::cast::<anyhow::error::ErrorImpl<gix_validate::reference::name::Error>>
Unexecuted instantiation: <anyhow::ptr::Ref<anyhow::error::ErrorImpl>>::cast::<anyhow::error::ErrorImpl<gix_ref::store_impl::packed::iter::error::Error>>
Unexecuted instantiation: <anyhow::ptr::Ref<anyhow::error::ErrorImpl>>::cast::<anyhow::error::ErrorImpl<gix_ref::store_impl::packed::buffer::open::error::Error>>
Unexecuted instantiation: <anyhow::ptr::Ref<gix_validate::reference::name::Error>>::cast::<()>
Unexecuted instantiation: <anyhow::ptr::Ref<gix_ref::store_impl::packed::iter::error::Error>>::cast::<()>
Unexecuted instantiation: <anyhow::ptr::Ref<gix_ref::store_impl::packed::buffer::open::error::Error>>::cast::<()>
Unexecuted instantiation: <anyhow::ptr::Ref<anyhow::error::ErrorImpl<gix_validate::reference::name::Error>>>::cast::<anyhow::error::ErrorImpl>
Unexecuted instantiation: <anyhow::ptr::Ref<anyhow::error::ErrorImpl>>::cast::<anyhow::error::ErrorImpl<gix_validate::reference::name::Error>>
Unexecuted instantiation: <anyhow::ptr::Ref<gix_validate::reference::name::Error>>::cast::<()>
Unexecuted instantiation: <anyhow::ptr::Ref<anyhow::error::ErrorImpl<std::io::error::Error>>>::cast::<anyhow::error::ErrorImpl>
Unexecuted instantiation: <anyhow::ptr::Ref<anyhow::error::ErrorImpl<gix_ref::store_impl::file::log::line::decode::error::Error>>>::cast::<anyhow::error::ErrorImpl>
Unexecuted instantiation: <anyhow::ptr::Ref<anyhow::error::ErrorImpl>>::cast::<anyhow::error::ErrorImpl<std::io::error::Error>>
Unexecuted instantiation: <anyhow::ptr::Ref<anyhow::error::ErrorImpl>>::cast::<anyhow::error::ErrorImpl<gix_ref::store_impl::file::log::line::decode::error::Error>>
Unexecuted instantiation: <anyhow::ptr::Ref<std::io::error::Error>>::cast::<()>
Unexecuted instantiation: <anyhow::ptr::Ref<gix_ref::store_impl::file::log::line::decode::error::Error>>::cast::<()>
Unexecuted instantiation: <anyhow::ptr::Ref<anyhow::error::ErrorImpl<gix_commitgraph::file::init::Error>>>::cast::<anyhow::error::ErrorImpl>
Unexecuted instantiation: <anyhow::ptr::Ref<anyhow::error::ErrorImpl<std::io::error::Error>>>::cast::<anyhow::error::ErrorImpl>
Unexecuted instantiation: <anyhow::ptr::Ref<anyhow::error::ErrorImpl>>::cast::<anyhow::error::ErrorImpl<gix_commitgraph::file::init::Error>>
Unexecuted instantiation: <anyhow::ptr::Ref<anyhow::error::ErrorImpl>>::cast::<anyhow::error::ErrorImpl<std::io::error::Error>>
Unexecuted instantiation: <anyhow::ptr::Ref<gix_commitgraph::file::init::Error>>::cast::<()>
Unexecuted instantiation: <anyhow::ptr::Ref<std::io::error::Error>>::cast::<()>
Unexecuted instantiation: <anyhow::ptr::Ref<anyhow::error::ErrorImpl<gix_url::parse::Error>>>::cast::<anyhow::error::ErrorImpl>
Unexecuted instantiation: <anyhow::ptr::Ref<anyhow::error::ErrorImpl>>::cast::<anyhow::error::ErrorImpl<gix_url::parse::Error>>
Unexecuted instantiation: <anyhow::ptr::Ref<gix_url::parse::Error>>::cast::<()>
Unexecuted instantiation: <anyhow::ptr::Ref<anyhow::error::ErrorImpl<gix_pathspec::parse::Error>>>::cast::<anyhow::error::ErrorImpl>
Unexecuted instantiation: <anyhow::ptr::Ref<anyhow::error::ErrorImpl>>::cast::<anyhow::error::ErrorImpl<gix_pathspec::parse::Error>>
Unexecuted instantiation: <anyhow::ptr::Ref<gix_pathspec::parse::Error>>::cast::<()>
108
109
    #[cfg(not(anyhow_no_ptr_addr_of))]
110
0
    pub fn by_mut(self) -> Mut<'a, T> {
111
0
        Mut {
112
0
            ptr: self.ptr,
113
0
            lifetime: PhantomData,
114
0
        }
115
0
    }
116
117
    #[cfg(not(anyhow_no_ptr_addr_of))]
118
4.66k
    pub fn as_ptr(self) -> *const T {
119
4.66k
        self.ptr.as_ptr() as *const T
120
4.66k
    }
Unexecuted instantiation: <anyhow::ptr::Ref<anyhow::error::ErrorImpl<gix_config::lookup::existing::Error>>>::as_ptr
Unexecuted instantiation: <anyhow::ptr::Ref<anyhow::error::ErrorImpl<gix_config::file::init::types::Error>>>::as_ptr
Unexecuted instantiation: <anyhow::ptr::Ref<anyhow::error::ErrorImpl<gix_config::parse::section::types::value_name::Error>>>::as_ptr
Unexecuted instantiation: <anyhow::ptr::Ref<anyhow::error::ErrorImpl<anyhow::wrapper::MessageError<alloc::string::String>>>>::as_ptr
Unexecuted instantiation: <anyhow::ptr::Ref<anyhow::error::ErrorImpl<anyhow::wrapper::MessageError<&str>>>>::as_ptr
Unexecuted instantiation: <anyhow::ptr::Ref<anyhow::error::ErrorImpl<alloc::boxed::Box<dyn core::error::Error + core::marker::Sync + core::marker::Send>>>>::as_ptr
Unexecuted instantiation: <anyhow::ptr::Ref<anyhow::error::ErrorImpl<anyhow::wrapper::BoxedError>>>::as_ptr
Unexecuted instantiation: <anyhow::ptr::Ref<anyhow::error::ErrorImpl<alloc::string::String>>>::as_ptr
Unexecuted instantiation: <anyhow::ptr::Ref<anyhow::error::ErrorImpl<&str>>>::as_ptr
<anyhow::ptr::Ref<anyhow::error::ErrorImpl<gix_config_value::Error>>>::as_ptr
Line
Count
Source
118
4.66k
    pub fn as_ptr(self) -> *const T {
119
4.66k
        self.ptr.as_ptr() as *const T
120
4.66k
    }
Unexecuted instantiation: <anyhow::ptr::Ref<anyhow::error::ErrorImpl<gix_validate::reference::name::Error>>>::as_ptr
Unexecuted instantiation: <anyhow::ptr::Ref<anyhow::error::ErrorImpl<gix_ref::store_impl::packed::iter::error::Error>>>::as_ptr
Unexecuted instantiation: <anyhow::ptr::Ref<anyhow::error::ErrorImpl<gix_ref::store_impl::packed::buffer::open::error::Error>>>::as_ptr
Unexecuted instantiation: <anyhow::ptr::Ref<anyhow::error::ErrorImpl<gix_validate::reference::name::Error>>>::as_ptr
Unexecuted instantiation: <anyhow::ptr::Ref<anyhow::error::ErrorImpl<std::io::error::Error>>>::as_ptr
Unexecuted instantiation: <anyhow::ptr::Ref<anyhow::error::ErrorImpl<gix_ref::store_impl::file::log::line::decode::error::Error>>>::as_ptr
Unexecuted instantiation: <anyhow::ptr::Ref<anyhow::error::ErrorImpl<gix_commitgraph::file::init::Error>>>::as_ptr
Unexecuted instantiation: <anyhow::ptr::Ref<anyhow::error::ErrorImpl<std::io::error::Error>>>::as_ptr
Unexecuted instantiation: <anyhow::ptr::Ref<anyhow::error::ErrorImpl<gix_url::parse::Error>>>::as_ptr
Unexecuted instantiation: <anyhow::ptr::Ref<anyhow::error::ErrorImpl<gix_pathspec::parse::Error>>>::as_ptr
121
122
6.99k
    pub unsafe fn deref(self) -> &'a T {
123
6.99k
        unsafe { &*self.ptr.as_ptr() }
124
6.99k
    }
<anyhow::ptr::Ref<dyn core::error::Error + core::marker::Sync + core::marker::Send>>::deref
Line
Count
Source
122
4.66k
    pub unsafe fn deref(self) -> &'a T {
123
4.66k
        unsafe { &*self.ptr.as_ptr() }
124
4.66k
    }
<anyhow::ptr::Ref<anyhow::error::ErrorImpl>>::deref
Line
Count
Source
122
2.33k
    pub unsafe fn deref(self) -> &'a T {
123
2.33k
        unsafe { &*self.ptr.as_ptr() }
124
2.33k
    }
125
}
126
127
#[repr(transparent)]
128
pub struct Mut<'a, T>
129
where
130
    T: ?Sized,
131
{
132
    pub ptr: NonNull<T>,
133
    lifetime: PhantomData<&'a mut T>,
134
}
135
136
impl<'a, T> Copy for Mut<'a, T> where T: ?Sized {}
137
138
impl<'a, T> Clone for Mut<'a, T>
139
where
140
    T: ?Sized,
141
{
142
0
    fn clone(&self) -> Self {
143
0
        *self
144
0
    }
145
}
146
147
impl<'a, T> Mut<'a, T>
148
where
149
    T: ?Sized,
150
{
151
    #[cfg(anyhow_no_ptr_addr_of)]
152
    pub fn new(ptr: &'a mut T) -> Self {
153
        Mut {
154
            ptr: NonNull::from(ptr),
155
            lifetime: PhantomData,
156
        }
157
    }
158
159
0
    pub fn cast<U: CastTo>(self) -> Mut<'a, U::Target> {
160
0
        Mut {
161
0
            ptr: self.ptr.cast(),
162
0
            lifetime: PhantomData,
163
0
        }
164
0
    }
165
166
    #[cfg(not(anyhow_no_ptr_addr_of))]
167
0
    pub fn by_ref(self) -> Ref<'a, T> {
168
0
        Ref {
169
0
            ptr: self.ptr,
170
0
            lifetime: PhantomData,
171
0
        }
172
0
    }
173
174
0
    pub fn extend<'b>(self) -> Mut<'b, T> {
175
0
        Mut {
176
0
            ptr: self.ptr,
177
0
            lifetime: PhantomData,
178
0
        }
179
0
    }
180
181
0
    pub unsafe fn deref_mut(self) -> &'a mut T {
182
0
        unsafe { &mut *self.ptr.as_ptr() }
183
0
    }
184
}
185
186
impl<'a, T> Mut<'a, T> {
187
0
    pub unsafe fn read(self) -> T {
188
0
        unsafe { self.ptr.as_ptr().read() }
189
0
    }
190
}
191
192
// Force turbofish on all calls of `.cast::<U>()`.
193
pub trait CastTo {
194
    type Target;
195
}
196
197
impl<T> CastTo for T {
198
    type Target = T;
199
}