Reborrow Pin<P> using &mut in Pin::set

This makes it possible to call `.set` multiple times without
using `.as_mut()` first to reborrow the pointer.
This commit is contained in:
Taylor Cramer 2019-01-07 11:45:34 -08:00
parent 21ac19d8fe
commit 68e98a2a85

View file

@ -175,11 +175,11 @@ impl<P: DerefMut> Pin<P> {
/// Assign a new value to the memory behind the pinned reference.
#[stable(feature = "pin", since = "1.33.0")]
#[inline(always)]
pub fn set(mut self: Pin<P>, value: P::Target)
pub fn set(self: &mut Pin<P>, value: P::Target)
where
P::Target: Sized,
{
*self.pointer = value;
*(self.pointer) = value;
}
}