cyberex/xself.rs
1use std::pin::Pin;
2
3/**
4
5 # Safety
6
7 This function is unsafe. You must guarantee that you will never move the data out of the
8 mutable reference you receive when you call this function, so that the invariants on the Pin type can be upheld.
9*/
10pub unsafe fn self_mut_from_pinbox<T>(p: &mut Pin<Box<T>>) -> &mut T {
11 p.as_mut().get_unchecked_mut()
12}
13pub fn self_from_pinbox<T>(p: &Pin<Box<T>>) -> &T {
14 p.as_ref().get_ref()
15}