1
Fork 0

Rollup merge of #64531 - taiki-e:pin-self, r=Centril

Use shorthand syntax in the self parameter of methods of Pin
This commit is contained in:
Mazdak Farrokhzad 2019-09-17 03:08:41 +02:00 committed by GitHub
commit a1fd9bae2c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -549,7 +549,7 @@ impl<P: Deref> Pin<P> {
/// ruled out by the contract of `Pin::new_unchecked`. /// ruled out by the contract of `Pin::new_unchecked`.
#[stable(feature = "pin", since = "1.33.0")] #[stable(feature = "pin", since = "1.33.0")]
#[inline(always)] #[inline(always)]
pub fn as_ref(self: &Pin<P>) -> Pin<&P::Target> { pub fn as_ref(&self) -> Pin<&P::Target> {
unsafe { Pin::new_unchecked(&*self.pointer) } unsafe { Pin::new_unchecked(&*self.pointer) }
} }
@ -586,7 +586,7 @@ impl<P: DerefMut> Pin<P> {
/// ruled out by the contract of `Pin::new_unchecked`. /// ruled out by the contract of `Pin::new_unchecked`.
#[stable(feature = "pin", since = "1.33.0")] #[stable(feature = "pin", since = "1.33.0")]
#[inline(always)] #[inline(always)]
pub fn as_mut(self: &mut Pin<P>) -> Pin<&mut P::Target> { pub fn as_mut(&mut self) -> Pin<&mut P::Target> {
unsafe { Pin::new_unchecked(&mut *self.pointer) } unsafe { Pin::new_unchecked(&mut *self.pointer) }
} }
@ -596,7 +596,7 @@ impl<P: DerefMut> Pin<P> {
/// run before being overwritten, so no pinning guarantee is violated. /// run before being overwritten, so no pinning guarantee is violated.
#[stable(feature = "pin", since = "1.33.0")] #[stable(feature = "pin", since = "1.33.0")]
#[inline(always)] #[inline(always)]
pub fn set(self: &mut Pin<P>, value: P::Target) pub fn set(&mut self, value: P::Target)
where where
P::Target: Sized, P::Target: Sized,
{ {
@ -621,7 +621,7 @@ impl<'a, T: ?Sized> Pin<&'a T> {
/// ///
/// [`pin` module]: ../../std/pin/index.html#projections-and-structural-pinning /// [`pin` module]: ../../std/pin/index.html#projections-and-structural-pinning
#[stable(feature = "pin", since = "1.33.0")] #[stable(feature = "pin", since = "1.33.0")]
pub unsafe fn map_unchecked<U, F>(self: Pin<&'a T>, func: F) -> Pin<&'a U> where pub unsafe fn map_unchecked<U, F>(self, func: F) -> Pin<&'a U> where
F: FnOnce(&T) -> &U, F: FnOnce(&T) -> &U,
{ {
let pointer = &*self.pointer; let pointer = &*self.pointer;
@ -648,7 +648,7 @@ impl<'a, T: ?Sized> Pin<&'a T> {
/// ["pinning projections"]: ../../std/pin/index.html#projections-and-structural-pinning /// ["pinning projections"]: ../../std/pin/index.html#projections-and-structural-pinning
#[stable(feature = "pin", since = "1.33.0")] #[stable(feature = "pin", since = "1.33.0")]
#[inline(always)] #[inline(always)]
pub fn get_ref(self: Pin<&'a T>) -> &'a T { pub fn get_ref(self) -> &'a T {
self.pointer self.pointer
} }
} }
@ -657,7 +657,7 @@ impl<'a, T: ?Sized> Pin<&'a mut T> {
/// Converts this `Pin<&mut T>` into a `Pin<&T>` with the same lifetime. /// Converts this `Pin<&mut T>` into a `Pin<&T>` with the same lifetime.
#[stable(feature = "pin", since = "1.33.0")] #[stable(feature = "pin", since = "1.33.0")]
#[inline(always)] #[inline(always)]
pub fn into_ref(self: Pin<&'a mut T>) -> Pin<&'a T> { pub fn into_ref(self) -> Pin<&'a T> {
Pin { pointer: self.pointer } Pin { pointer: self.pointer }
} }
@ -672,7 +672,7 @@ impl<'a, T: ?Sized> Pin<&'a mut T> {
/// with the same lifetime as the original `Pin`. /// with the same lifetime as the original `Pin`.
#[stable(feature = "pin", since = "1.33.0")] #[stable(feature = "pin", since = "1.33.0")]
#[inline(always)] #[inline(always)]
pub fn get_mut(self: Pin<&'a mut T>) -> &'a mut T pub fn get_mut(self) -> &'a mut T
where T: Unpin, where T: Unpin,
{ {
self.pointer self.pointer
@ -690,7 +690,7 @@ impl<'a, T: ?Sized> Pin<&'a mut T> {
/// instead. /// instead.
#[stable(feature = "pin", since = "1.33.0")] #[stable(feature = "pin", since = "1.33.0")]
#[inline(always)] #[inline(always)]
pub unsafe fn get_unchecked_mut(self: Pin<&'a mut T>) -> &'a mut T { pub unsafe fn get_unchecked_mut(self) -> &'a mut T {
self.pointer self.pointer
} }
@ -710,7 +710,7 @@ impl<'a, T: ?Sized> Pin<&'a mut T> {
/// ///
/// [`pin` module]: ../../std/pin/index.html#projections-and-structural-pinning /// [`pin` module]: ../../std/pin/index.html#projections-and-structural-pinning
#[stable(feature = "pin", since = "1.33.0")] #[stable(feature = "pin", since = "1.33.0")]
pub unsafe fn map_unchecked_mut<U, F>(self: Pin<&'a mut T>, func: F) -> Pin<&'a mut U> where pub unsafe fn map_unchecked_mut<U, F>(self, func: F) -> Pin<&'a mut U> where
F: FnOnce(&mut T) -> &mut U, F: FnOnce(&mut T) -> &mut U,
{ {
let pointer = Pin::get_unchecked_mut(self); let pointer = Pin::get_unchecked_mut(self);