Change PinMut::map to be able to preserve the original reference's lifetime

Suggested by @dylanede at <https://github.com/rust-lang/rust/issues/49150#issuecomment-381071442>.
This commit is contained in:
Ralf Jung 2018-05-07 12:51:59 +02:00
parent 9f26376281
commit 84ce206db6

View File

@ -1155,7 +1155,7 @@ impl<'a, T: ?Sized> PinMut<'a, T> {
/// because it is one of the fields of that value), and also that you do
/// not move out of the argument you receive to the interior function.
#[unstable(feature = "pin", issue = "49150")]
pub unsafe fn map<'b, U, F>(this: &'b mut PinMut<'a, T>, f: F) -> PinMut<'b, U> where
pub unsafe fn map<U, F>(this: PinMut<'a, T>, f: F) -> PinMut<'a, U> where
F: FnOnce(&mut T) -> &mut U
{
PinMut { inner: f(this.inner) }