Debian Codegraph @

src/ptr.rs

raw symbols SCIP
1 use allocrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc crate/::boxedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/::Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#;
2 use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::markerrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/::PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#;
3 use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::ptrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ptr/::NonNullrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ptr/non_null/NonNull#;
4
5 #[repr(transparent)]
6 pub struct Ownrust-analyzer cargo anyhow 1.0.103 ptr/Own#<T>
7 where
8 T: ?Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized#,
9 {
10 pub ptrrust-analyzer cargo anyhow 1.0.103 ptr/Own#ptr.: NonNullrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ptr/non_null/NonNull#<T>,
11 }
12
13 unsafe impl<T> Sendrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Send# for Ownrust-analyzer cargo anyhow 1.0.103 ptr/Own#<T> where T: ?Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized# {}
14
15 unsafe impl<T> Syncrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sync# for Ownrust-analyzer cargo anyhow 1.0.103 ptr/Own#<T> where T: ?Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized# {}
16
17 impl<T> Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy# for Ownrust-analyzer cargo anyhow 1.0.103 ptr/Own#<T> where T: ?Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized# {}
18
19 impl<T> Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone# for Ownrust-analyzer cargo anyhow 1.0.103 ptr/Own#<T>
20 where
21 T: ?Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized#,
22 {
23 fn clonerust-analyzer cargo anyhow 1.0.103 ptr/impl#[`Own<T>`][Clone]clone().(&self) -> Selfrust-analyzer cargo anyhow 1.0.103 ptr/impl#[`Own<T>`][Clone] {
24 *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self
25 }
26 }
27
28 impl<T> Ownrust-analyzer cargo anyhow 1.0.103 ptr/Own#<T>
29 where
30 T: ?Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized#,
31 {
32 pub fn newrust-analyzer cargo anyhow 1.0.103 ptr/impl#[`Own<T>`]new().(ptr: Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<T>) -> Selfrust-analyzer cargo anyhow 1.0.103 ptr/impl#[`Own<T>`] {
33 Ownrust-analyzer cargo anyhow 1.0.103 ptr/Own# {
34 ptrrust-analyzer cargo anyhow 1.0.103 ptr/Own#ptr.: unsafe { NonNullrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ptr/non_null/NonNull#::new_uncheckedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ptr/non_null/impl#[`NonNull<T>`]new_unchecked().(Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#::into_rawrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T>`]into_raw().(ptr)) },
35 }
36 }
37
38 pub fn castrust-analyzer cargo anyhow 1.0.103 ptr/impl#[`Own<T>`]cast().<U: CastTorust-analyzer cargo anyhow 1.0.103 ptr/CastTo#>(self) -> Ownrust-analyzer cargo anyhow 1.0.103 ptr/Own#<U::Targetrust-analyzer cargo anyhow 1.0.103 ptr/CastTo#Target#> {
39 Ownrust-analyzer cargo anyhow 1.0.103 ptr/Own# {
40 ptrrust-analyzer cargo anyhow 1.0.103 ptr/Own#ptr.: self.ptrrust-analyzer cargo anyhow 1.0.103 ptr/Own#ptr..castrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ptr/non_null/impl#[`NonNull<T>`]cast().(),
41 }
42 }
43
44 pub unsafe fn boxedrust-analyzer cargo anyhow 1.0.103 ptr/impl#[`Own<T>`]boxed().(self) -> Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<T> {
45 unsafe { Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#::from_rawrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T>`]from_raw().(self.ptrrust-analyzer cargo anyhow 1.0.103 ptr/Own#ptr..as_ptrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ptr/non_null/impl#[`NonNull<T>`]as_ptr().()) }
46 }
47
48 pub fn by_refrust-analyzer cargo anyhow 1.0.103 ptr/impl#[`Own<T>`]by_ref().(&self) -> Refrust-analyzer cargo anyhow 1.0.103 ptr/Ref#<T> {
49 Refrust-analyzer cargo anyhow 1.0.103 ptr/Ref# {
50 ptrrust-analyzer cargo anyhow 1.0.103 ptr/Ref#ptr.: self.ptrrust-analyzer cargo anyhow 1.0.103 ptr/Own#ptr.,
51 lifetimerust-analyzer cargo anyhow 1.0.103 ptr/Ref#lifetime.: PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#,
52 }
53 }
54
55 pub fn by_mutrust-analyzer cargo anyhow 1.0.103 ptr/impl#[`Own<T>`]by_mut().(&mut self) -> Mutrust-analyzer cargo anyhow 1.0.103 ptr/Mut#<T> {
56 Mutrust-analyzer cargo anyhow 1.0.103 ptr/Mut# {
57 ptrrust-analyzer cargo anyhow 1.0.103 ptr/Mut#ptr.: self.ptrrust-analyzer cargo anyhow 1.0.103 ptr/Own#ptr.,
58 lifetimerust-analyzer cargo anyhow 1.0.103 ptr/Mut#lifetime.: PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#,
59 }
60 }
61 }
62
63 #[repr(transparent)]
64 pub struct Refrust-analyzer cargo anyhow 1.0.103 ptr/Ref#<'a, T>
65 where
66 T: ?Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized#,
67 {
68 pub ptrrust-analyzer cargo anyhow 1.0.103 ptr/Ref#ptr.: NonNullrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ptr/non_null/NonNull#<T>,
69 lifetimerust-analyzer cargo anyhow 1.0.103 ptr/Ref#lifetime.: PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#<&'a T>,
70 }
71
72 impl<'a, T> Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy# for Refrust-analyzer cargo anyhow 1.0.103 ptr/Ref#<'a, T> where T: ?Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized# {}
73
74 impl<'a, T> Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone# for Refrust-analyzer cargo anyhow 1.0.103 ptr/Ref#<'a, T>
75 where
76 T: ?Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized#,
77 {
78 fn clonerust-analyzer cargo anyhow 1.0.103 ptr/impl#[`Ref<'a, T>`][Clone]clone().(&self) -> Selfrust-analyzer cargo anyhow 1.0.103 ptr/impl#[`Ref<'a, T>`][Clone] {
79 *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self
80 }
81 }
82
83 impl<'a, T> Refrust-analyzer cargo anyhow 1.0.103 ptr/Ref#<'a, T>
84 where
85 T: ?Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized#,
86 {
87 pub fn newrust-analyzer cargo anyhow 1.0.103 ptr/impl#[`Ref<'a, T>`]new().(ptr: &'a T) -> Selfrust-analyzer cargo anyhow 1.0.103 ptr/impl#[`Ref<'a, T>`] {
88 Refrust-analyzer cargo anyhow 1.0.103 ptr/Ref# {
89 ptrrust-analyzer cargo anyhow 1.0.103 ptr/Ref#ptr.: NonNullrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ptr/non_null/NonNull#::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ptr/non_null/impl#[`NonNull<T>`][`From<&T>`]from().(ptr),
90 lifetimerust-analyzer cargo anyhow 1.0.103 ptr/Ref#lifetime.: PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#,
91 }
92 }
93
94 pub fn from_rawrust-analyzer cargo anyhow 1.0.103 ptr/impl#[`Ref<'a, T>`]from_raw().(ptr: NonNullrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ptr/non_null/NonNull#<T>) -> Selfrust-analyzer cargo anyhow 1.0.103 ptr/impl#[`Ref<'a, T>`] {
95 Refrust-analyzer cargo anyhow 1.0.103 ptr/Ref# {
96 ptrrust-analyzer cargo anyhow 1.0.103 ptr/Ref#ptr.,
97 lifetimerust-analyzer cargo anyhow 1.0.103 ptr/Ref#lifetime.: PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#,
98 }
99 }
100
101 pub fn castrust-analyzer cargo anyhow 1.0.103 ptr/impl#[`Ref<'a, T>`]cast().<U: CastTorust-analyzer cargo anyhow 1.0.103 ptr/CastTo#>(self) -> Refrust-analyzer cargo anyhow 1.0.103 ptr/Ref#<'a, U::Targetrust-analyzer cargo anyhow 1.0.103 ptr/CastTo#Target#> {
102 Refrust-analyzer cargo anyhow 1.0.103 ptr/Ref# {
103 ptrrust-analyzer cargo anyhow 1.0.103 ptr/Ref#ptr.: self.ptrrust-analyzer cargo anyhow 1.0.103 ptr/Ref#ptr..castrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ptr/non_null/impl#[`NonNull<T>`]cast().(),
104 lifetimerust-analyzer cargo anyhow 1.0.103 ptr/Ref#lifetime.: PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#,
105 }
106 }
107
108 pub fn by_mutrust-analyzer cargo anyhow 1.0.103 ptr/impl#[`Ref<'a, T>`]by_mut().(self) -> Mutrust-analyzer cargo anyhow 1.0.103 ptr/Mut#<'a, T> {
109 Mutrust-analyzer cargo anyhow 1.0.103 ptr/Mut# {
110 ptrrust-analyzer cargo anyhow 1.0.103 ptr/Mut#ptr.: self.ptrrust-analyzer cargo anyhow 1.0.103 ptr/Ref#ptr.,
111 lifetimerust-analyzer cargo anyhow 1.0.103 ptr/Mut#lifetime.: PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#,
112 }
113 }
114
115 pub fn as_ptrrust-analyzer cargo anyhow 1.0.103 ptr/impl#[`Ref<'a, T>`]as_ptr().(self) -> *const T {
116 self.ptrrust-analyzer cargo anyhow 1.0.103 ptr/Ref#ptr..as_ptrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ptr/non_null/impl#[`NonNull<T>`]as_ptr().().cast_construst-analyzer cargo core https://github.com/rust-lang/rust/library/core ptr/mut_ptr/impl#[`*mut T`]cast_const().()
117 }
118
119 pub unsafe fn derefrust-analyzer cargo anyhow 1.0.103 ptr/impl#[`Ref<'a, T>`]deref().(self) -> &'a T {
120 unsafe { &*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/Deref#deref().self.ptrrust-analyzer cargo anyhow 1.0.103 ptr/Ref#ptr..as_ptrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ptr/non_null/impl#[`NonNull<T>`]as_ptr().() }
121 }
122 }
123
124 #[repr(transparent)]
125 pub struct Mutrust-analyzer cargo anyhow 1.0.103 ptr/Mut#<'a, T>
126 where
127 T: ?Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized#,
128 {
129 pub ptrrust-analyzer cargo anyhow 1.0.103 ptr/Mut#ptr.: NonNullrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ptr/non_null/NonNull#<T>,
130 lifetimerust-analyzer cargo anyhow 1.0.103 ptr/Mut#lifetime.: PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#<&'a mut T>,
131 }
132
133 impl<'a, T> Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy# for Mutrust-analyzer cargo anyhow 1.0.103 ptr/Mut#<'a, T> where T: ?Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized# {}
134
135 impl<'a, T> Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone# for Mutrust-analyzer cargo anyhow 1.0.103 ptr/Mut#<'a, T>
136 where
137 T: ?Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized#,
138 {
139 fn clonerust-analyzer cargo anyhow 1.0.103 ptr/impl#[`Mut<'a, T>`][Clone]clone().(&self) -> Selfrust-analyzer cargo anyhow 1.0.103 ptr/impl#[`Mut<'a, T>`][Clone] {
140 *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self
141 }
142 }
143
144 impl<'a, T> Mutrust-analyzer cargo anyhow 1.0.103 ptr/Mut#<'a, T>
145 where
146 T: ?Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized#,
147 {
148 pub fn castrust-analyzer cargo anyhow 1.0.103 ptr/impl#[`Mut<'a, T>`]cast().<U: CastTorust-analyzer cargo anyhow 1.0.103 ptr/CastTo#>(self) -> Mutrust-analyzer cargo anyhow 1.0.103 ptr/Mut#<'a, U::Targetrust-analyzer cargo anyhow 1.0.103 ptr/CastTo#Target#> {
149 Mutrust-analyzer cargo anyhow 1.0.103 ptr/Mut# {
150 ptrrust-analyzer cargo anyhow 1.0.103 ptr/Mut#ptr.: self.ptrrust-analyzer cargo anyhow 1.0.103 ptr/Mut#ptr..castrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ptr/non_null/impl#[`NonNull<T>`]cast().(),
151 lifetimerust-analyzer cargo anyhow 1.0.103 ptr/Mut#lifetime.: PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#,
152 }
153 }
154
155 pub fn by_refrust-analyzer cargo anyhow 1.0.103 ptr/impl#[`Mut<'a, T>`]by_ref().(self) -> Refrust-analyzer cargo anyhow 1.0.103 ptr/Ref#<'a, T> {
156 Refrust-analyzer cargo anyhow 1.0.103 ptr/Ref# {
157 ptrrust-analyzer cargo anyhow 1.0.103 ptr/Ref#ptr.: self.ptrrust-analyzer cargo anyhow 1.0.103 ptr/Mut#ptr.,
158 lifetimerust-analyzer cargo anyhow 1.0.103 ptr/Ref#lifetime.: PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#,
159 }
160 }
161
162 pub fn extendrust-analyzer cargo anyhow 1.0.103 ptr/impl#[`Mut<'a, T>`]extend().<'b>(self) -> Mutrust-analyzer cargo anyhow 1.0.103 ptr/Mut#<'b, T> {
163 Mutrust-analyzer cargo anyhow 1.0.103 ptr/Mut# {
164 ptrrust-analyzer cargo anyhow 1.0.103 ptr/Mut#ptr.: self.ptrrust-analyzer cargo anyhow 1.0.103 ptr/Mut#ptr.,
165 lifetimerust-analyzer cargo anyhow 1.0.103 ptr/Mut#lifetime.: PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#,
166 }
167 }
168
169 pub unsafe fn deref_mutrust-analyzer cargo anyhow 1.0.103 ptr/impl#[`Mut<'a, T>`]deref_mut().(self) -> &'a mut T {
170 unsafe { &mut *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/Deref#deref().self.ptrrust-analyzer cargo anyhow 1.0.103 ptr/Mut#ptr..as_ptrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ptr/non_null/impl#[`NonNull<T>`]as_ptr().() }
171 }
172 }
173
174 impl<'a, T> Mutrust-analyzer cargo anyhow 1.0.103 ptr/Mut#<'a, T> {
175 pub unsafe fn readrust-analyzer cargo anyhow 1.0.103 ptr/impl#[`Mut<'a, T>`]read().(self) -> T {
176 unsafe { self.ptrrust-analyzer cargo anyhow 1.0.103 ptr/Mut#ptr..as_ptrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ptr/non_null/impl#[`NonNull<T>`]as_ptr().().readrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ptr/mut_ptr/impl#[`*mut T`]read().() }
177 }
178 }
179
180 // Force turbofish on all calls of `.cast::<U>()`.
181 pub trait CastTorust-analyzer cargo anyhow 1.0.103 ptr/CastTo# {
182 type Targetrust-analyzer cargo anyhow 1.0.103 ptr/CastTo#Target#;
183 }
184
185 impl<T> CastTorust-analyzer cargo anyhow 1.0.103 ptr/CastTo# for T {
186 type Targetrust-analyzer cargo anyhow 1.0.103 ptr/impl#[T][CastTo]Target# = T;
187 }