1use crate::marker::PointeeSized;
2
3#[lang = "deref"]
134#[doc(alias = "*")]
135#[doc(alias = "&*")]
136#[stable(feature = "rust1", since = "1.0.0")]
137#[rustc_diagnostic_item = "Deref"]
138#[const_trait]
139#[rustc_const_unstable(feature = "const_deref", issue = "88955")]
140pub trait Deref: PointeeSized {
141 #[stable(feature = "rust1", since = "1.0.0")]
143 #[rustc_diagnostic_item = "deref_target"]
144 #[lang = "deref_target"]
145 type Target: ?Sized;
146
147 #[must_use]
149 #[stable(feature = "rust1", since = "1.0.0")]
150 #[rustc_diagnostic_item = "deref_method"]
151 fn deref(&self) -> &Self::Target;
152}
153
154#[stable(feature = "rust1", since = "1.0.0")]
155#[rustc_const_unstable(feature = "const_deref", issue = "88955")]
156impl<T: ?Sized> const Deref for &T {
157 type Target = T;
158
159 #[rustc_diagnostic_item = "noop_method_deref"]
160 fn deref(&self) -> &T {
161 self
162 }
163}
164
165#[stable(feature = "rust1", since = "1.0.0")]
166impl<T: ?Sized> !DerefMut for &T {}
167
168#[stable(feature = "rust1", since = "1.0.0")]
169#[rustc_const_unstable(feature = "const_deref", issue = "88955")]
170impl<T: ?Sized> const Deref for &mut T {
171 type Target = T;
172
173 fn deref(&self) -> &T {
174 self
175 }
176}
177
178#[lang = "deref_mut"]
268#[doc(alias = "*")]
269#[stable(feature = "rust1", since = "1.0.0")]
270#[const_trait]
271#[rustc_const_unstable(feature = "const_deref", issue = "88955")]
272pub trait DerefMut: [const] Deref + PointeeSized {
273 #[stable(feature = "rust1", since = "1.0.0")]
275 #[rustc_diagnostic_item = "deref_mut_method"]
276 fn deref_mut(&mut self) -> &mut Self::Target;
277}
278
279#[stable(feature = "rust1", since = "1.0.0")]
280#[rustc_const_unstable(feature = "const_deref", issue = "88955")]
281impl<T: ?Sized> const DerefMut for &mut T {
282 fn deref_mut(&mut self) -> &mut T {
283 self
284 }
285}
286
287#[unstable(feature = "deref_pure_trait", issue = "87121")]
297#[lang = "deref_pure"]
298pub unsafe trait DerefPure: PointeeSized {}
299
300#[unstable(feature = "deref_pure_trait", issue = "87121")]
301unsafe impl<T: ?Sized> DerefPure for &T {}
302
303#[unstable(feature = "deref_pure_trait", issue = "87121")]
304unsafe impl<T: ?Sized> DerefPure for &mut T {}
305
306#[lang = "receiver"]
370#[unstable(feature = "arbitrary_self_types", issue = "44874")]
371pub trait Receiver: PointeeSized {
372 #[rustc_diagnostic_item = "receiver_target"]
374 #[lang = "receiver_target"]
375 #[unstable(feature = "arbitrary_self_types", issue = "44874")]
376 type Target: ?Sized;
377}
378
379#[unstable(feature = "arbitrary_self_types", issue = "44874")]
380impl<P: ?Sized, T: ?Sized> Receiver for P
381where
382 P: Deref<Target = T>,
383{
384 type Target = T;
385}
386
387#[lang = "legacy_receiver"]
396#[unstable(feature = "legacy_receiver_trait", issue = "none")]
397#[doc(hidden)]
398pub trait LegacyReceiver: PointeeSized {
399 }
401
402#[unstable(feature = "legacy_receiver_trait", issue = "none")]
403impl<T: PointeeSized> LegacyReceiver for &T {}
404
405#[unstable(feature = "legacy_receiver_trait", issue = "none")]
406impl<T: PointeeSized> LegacyReceiver for &mut T {}
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4