#![feature(negative_impls)] #[lang = "sized"] trait Sized {} #[lang = "deref"] pub trait Deref { /// The resulting type after dereferencing. #[stable(feature = "rust1", since = "1.0.0")] // #[rustc_diagnostic_item = "deref_target"] type Target: ?Sized; /// Dereferences the value. #[must_use] #[stable(feature = "rust1", since = "1.0.0")] // #[rustc_diagnostic_item = "deref_method"] fn deref(&self) -> &Self::Target; } impl Deref for &T { type Target = T; fn deref(&self) -> &T { *self } } impl !DerefMut for &T {} impl Deref for &mut T { type Target = T; fn deref(&self) -> &T { *self } } #[lang = "deref_mut"] pub trait DerefMut: Deref { /// Mutably dereferences the value. #[stable(feature = "rust1", since = "1.0.0")] fn deref_mut(&mut self) -> &mut Self::Target; } impl DerefMut for &mut T { fn deref_mut(&mut self) -> &mut T { *self } }