-
-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
704 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
use pin_project::pin_project; | ||
# [ pin ( __private ( Replace , project = Proj , project_ref = ProjRef , project_replace = ProjOwn ) ) ] | ||
enum Enum<T, U> { | ||
Struct { | ||
#[pin] | ||
pinned: T, | ||
unpinned: U, | ||
}, | ||
Tuple(#[pin] T, U), | ||
Unit, | ||
} | ||
#[allow(clippy::mut_mut)] | ||
#[allow(dead_code)] | ||
#[allow(single_use_lifetimes)] | ||
enum Proj<'pin, T, U> | ||
where | ||
Enum<T, U>: 'pin, | ||
{ | ||
Struct { | ||
pinned: ::pin_project::__reexport::pin::Pin<&'pin mut (T)>, | ||
unpinned: &'pin mut (U), | ||
}, | ||
Tuple( | ||
::pin_project::__reexport::pin::Pin<&'pin mut (T)>, | ||
&'pin mut (U), | ||
), | ||
Unit, | ||
} | ||
#[allow(dead_code)] | ||
#[allow(single_use_lifetimes)] | ||
enum ProjRef<'pin, T, U> | ||
where | ||
Enum<T, U>: 'pin, | ||
{ | ||
Struct { | ||
pinned: ::pin_project::__reexport::pin::Pin<&'pin (T)>, | ||
unpinned: &'pin (U), | ||
}, | ||
Tuple(::pin_project::__reexport::pin::Pin<&'pin (T)>, &'pin (U)), | ||
Unit, | ||
} | ||
#[allow(dead_code)] | ||
#[allow(single_use_lifetimes)] | ||
enum ProjOwn<T, U> { | ||
Struct { | ||
pinned: ::pin_project::__reexport::marker::PhantomData<T>, | ||
unpinned: U, | ||
}, | ||
Tuple(::pin_project::__reexport::marker::PhantomData<T>, U), | ||
Unit, | ||
} | ||
#[doc(hidden)] | ||
#[allow(non_upper_case_globals)] | ||
#[allow(single_use_lifetimes)] | ||
const __SCOPE_Enum: () = { | ||
impl<T, U> Enum<T, U> { | ||
fn project<'pin>( | ||
self: ::pin_project::__reexport::pin::Pin<&'pin mut Self>, | ||
) -> Proj<'pin, T, U> { | ||
unsafe { | ||
match self.get_unchecked_mut() { | ||
Enum::Struct { pinned, unpinned } => Proj::Struct { | ||
pinned: ::pin_project::__reexport::pin::Pin::new_unchecked(pinned), | ||
unpinned, | ||
}, | ||
Enum::Tuple(_0, _1) => { | ||
Proj::Tuple(::pin_project::__reexport::pin::Pin::new_unchecked(_0), _1) | ||
} | ||
Enum::Unit => Proj::Unit, | ||
} | ||
} | ||
} | ||
fn project_ref<'pin>( | ||
self: ::pin_project::__reexport::pin::Pin<&'pin Self>, | ||
) -> ProjRef<'pin, T, U> { | ||
unsafe { | ||
match self.get_ref() { | ||
Enum::Struct { pinned, unpinned } => ProjRef::Struct { | ||
pinned: ::pin_project::__reexport::pin::Pin::new_unchecked(pinned), | ||
unpinned, | ||
}, | ||
Enum::Tuple(_0, _1) => { | ||
ProjRef::Tuple(::pin_project::__reexport::pin::Pin::new_unchecked(_0), _1) | ||
} | ||
Enum::Unit => ProjRef::Unit, | ||
} | ||
} | ||
} | ||
fn project_replace( | ||
self: ::pin_project::__reexport::pin::Pin<&mut Self>, | ||
__replacement: Self, | ||
) -> ProjOwn<T, U> { | ||
unsafe { | ||
let __self_ptr: *mut Self = self.get_unchecked_mut(); | ||
match &mut *__self_ptr { | ||
Enum::Struct { pinned, unpinned } => { | ||
let __result = ProjOwn::Struct { | ||
pinned: ::pin_project::__reexport::marker::PhantomData, | ||
unpinned: ::pin_project::__reexport::ptr::read(unpinned), | ||
}; | ||
let __guard = ::pin_project::__private::UnsafeOverwriteGuard { | ||
target: __self_ptr, | ||
value: ::pin_project::__reexport::mem::ManuallyDrop::new(__replacement), | ||
}; | ||
{ | ||
let __guard = ::pin_project::__private::UnsafeDropInPlaceGuard(pinned); | ||
} | ||
__result | ||
} | ||
Enum::Tuple(_0, _1) => { | ||
let __result = ProjOwn::Tuple( | ||
::pin_project::__reexport::marker::PhantomData, | ||
::pin_project::__reexport::ptr::read(_1), | ||
); | ||
let __guard = ::pin_project::__private::UnsafeOverwriteGuard { | ||
target: __self_ptr, | ||
value: ::pin_project::__reexport::mem::ManuallyDrop::new(__replacement), | ||
}; | ||
{ | ||
let __guard = ::pin_project::__private::UnsafeDropInPlaceGuard(_0); | ||
} | ||
__result | ||
} | ||
Enum::Unit => { | ||
let __result = ProjOwn::Unit; | ||
let __guard = ::pin_project::__private::UnsafeOverwriteGuard { | ||
target: __self_ptr, | ||
value: ::pin_project::__reexport::mem::ManuallyDrop::new(__replacement), | ||
}; | ||
{} | ||
__result | ||
} | ||
} | ||
} | ||
} | ||
} | ||
struct __Enum<'pin, T, U> { | ||
__pin_project_use_generics: ::pin_project::__private::AlwaysUnpin<'pin, (T, U)>, | ||
__field0: T, | ||
__field1: T, | ||
} | ||
impl<'pin, T, U> ::pin_project::__reexport::marker::Unpin for Enum<T, U> where | ||
__Enum<'pin, T, U>: ::pin_project::__reexport::marker::Unpin | ||
{ | ||
} | ||
unsafe impl<T, U> ::pin_project::UnsafeUnpin for Enum<T, U> {} | ||
trait EnumMustNotImplDrop {} | ||
#[allow(clippy::drop_bounds)] | ||
impl<T: ::pin_project::__reexport::ops::Drop> EnumMustNotImplDrop for T {} | ||
impl<T, U> EnumMustNotImplDrop for Enum<T, U> {} | ||
impl<T, U> ::pin_project::__private::PinnedDrop for Enum<T, U> { | ||
unsafe fn drop(self: ::pin_project::__reexport::pin::Pin<&mut Self>) {} | ||
} | ||
}; | ||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
use pin_project::pin_project; | ||
|
||
#[pin_project(Replace, project = Proj, project_ref = ProjRef, project_replace = ProjOwn)] | ||
enum Enum<T, U> { | ||
Struct { | ||
#[pin] | ||
pinned: T, | ||
unpinned: U, | ||
}, | ||
Tuple(#[pin] T, U), | ||
Unit, | ||
} | ||
|
||
fn main() {} |
Oops, something went wrong.