1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use core::{ops, pin::Pin};

/// The equivalent of `DerefMut` for `!Unpin` types.
///
/// The target is unpinned. It doesn't override dereference operations (like
/// `*smart_ptr`).
pub trait PinDerefMut: ops::Deref {
    fn pin_deref_mut(self: Pin<&mut Self>) -> &mut Self::Target;
}

impl<T: ?Sized> PinDerefMut for &mut T {
    #[inline]
    fn pin_deref_mut(self: Pin<&mut Self>) -> &mut Self::Target {
        *Pin::into_inner(self)
    }
}