Skip to content

Commit

Permalink
Inline project methods (#74)
Browse files Browse the repository at this point in the history
  • Loading branch information
EFanZh authored Jul 2, 2023
1 parent ba78c67 commit 59f83eb
Show file tree
Hide file tree
Showing 16 changed files with 35 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -954,6 +954,7 @@ macro_rules! __pin_project_struct_make_proj_method {
),+
}
) => {
#[inline]
$proj_vis fn $method_ident<'__pin>(
self: $crate::__private::Pin<&'__pin $($mut)? Self>,
) -> $proj_ty_ident <'__pin, $($ty_generics)*> {
Expand Down Expand Up @@ -987,6 +988,7 @@ macro_rules! __pin_project_struct_make_proj_replace_method {
),+
}
) => {
#[inline]
$proj_vis fn project_replace(
self: $crate::__private::Pin<&mut Self>,
replacement: Self,
Expand Down Expand Up @@ -1034,6 +1036,7 @@ macro_rules! __pin_project_enum_make_proj_method {
),+
}
) => {
#[inline]
$proj_vis fn $method_ident<'__pin>(
self: $crate::__private::Pin<&'__pin $($mut)? Self>,
) -> $proj_ty_ident <'__pin, $($ty_generics)*> {
Expand Down Expand Up @@ -1077,6 +1080,7 @@ macro_rules! __pin_project_enum_make_proj_replace_method {
),+
}
) => {
#[inline]
$proj_vis fn project_replace(
self: $crate::__private::Pin<&mut Self>,
replacement: Self,
Expand Down
3 changes: 3 additions & 0 deletions tests/expand/default/enum.expanded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ enum EnumProjReplace<T, U> {
#[allow(clippy::used_underscore_binding)]
const _: () = {
impl<T, U> Enum<T, U> {
#[inline]
fn project<'__pin>(
self: ::pin_project_lite::__private::Pin<&'__pin mut Self>,
) -> EnumProj<'__pin, T, U> {
Expand All @@ -68,6 +69,7 @@ const _: () = {
}
}
}
#[inline]
fn project_ref<'__pin>(
self: ::pin_project_lite::__private::Pin<&'__pin Self>,
) -> EnumProjRef<'__pin, T, U> {
Expand All @@ -85,6 +87,7 @@ const _: () = {
}
}
}
#[inline]
fn project_replace(
self: ::pin_project_lite::__private::Pin<&mut Self>,
replacement: Self,
Expand Down
2 changes: 2 additions & 0 deletions tests/expand/default/struct.expanded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const _: () = {
unpinned: &'__pin (U),
}
impl<T, U> Struct<T, U> {
#[inline]
fn project<'__pin>(
self: ::pin_project_lite::__private::Pin<&'__pin mut Self>,
) -> Projection<'__pin, T, U> {
Expand All @@ -49,6 +50,7 @@ const _: () = {
}
}
}
#[inline]
fn project_ref<'__pin>(
self: ::pin_project_lite::__private::Pin<&'__pin Self>,
) -> ProjectionRef<'__pin, T, U> {
Expand Down
1 change: 1 addition & 0 deletions tests/expand/multifields/enum.expanded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ enum EnumProjReplace<T, U> {
#[allow(clippy::used_underscore_binding)]
const _: () = {
impl<T, U> Enum<T, U> {
#[inline]
fn project_replace(
self: ::pin_project_lite::__private::Pin<&mut Self>,
replacement: Self,
Expand Down
3 changes: 3 additions & 0 deletions tests/expand/multifields/struct.expanded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ const _: () = {
unpinned2: &'__pin (U),
}
impl<T, U> Struct<T, U> {
#[inline]
fn project<'__pin>(
self: ::pin_project_lite::__private::Pin<&'__pin mut Self>,
) -> Projection<'__pin, T, U> {
Expand All @@ -69,6 +70,7 @@ const _: () = {
}
}
}
#[inline]
fn project_ref<'__pin>(
self: ::pin_project_lite::__private::Pin<&'__pin Self>,
) -> ProjectionRef<'__pin, T, U> {
Expand All @@ -82,6 +84,7 @@ const _: () = {
}
}
}
#[inline]
fn project_replace(
self: ::pin_project_lite::__private::Pin<&mut Self>,
replacement: Self,
Expand Down
3 changes: 3 additions & 0 deletions tests/expand/naming/enum-all.expanded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ enum EnumProjReplace<T, U> {
#[allow(clippy::used_underscore_binding)]
const _: () = {
impl<T, U> Enum<T, U> {
#[inline]
fn project<'__pin>(
self: ::pin_project_lite::__private::Pin<&'__pin mut Self>,
) -> EnumProj<'__pin, T, U> {
Expand All @@ -68,6 +69,7 @@ const _: () = {
}
}
}
#[inline]
fn project_ref<'__pin>(
self: ::pin_project_lite::__private::Pin<&'__pin Self>,
) -> EnumProjRef<'__pin, T, U> {
Expand All @@ -85,6 +87,7 @@ const _: () = {
}
}
}
#[inline]
fn project_replace(
self: ::pin_project_lite::__private::Pin<&mut Self>,
replacement: Self,
Expand Down
1 change: 1 addition & 0 deletions tests/expand/naming/enum-mut.expanded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ where
#[allow(clippy::used_underscore_binding)]
const _: () = {
impl<T, U> Enum<T, U> {
#[inline]
fn project<'__pin>(
self: ::pin_project_lite::__private::Pin<&'__pin mut Self>,
) -> EnumProj<'__pin, T, U> {
Expand Down
1 change: 1 addition & 0 deletions tests/expand/naming/enum-ref.expanded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ where
#[allow(clippy::used_underscore_binding)]
const _: () = {
impl<T, U> Enum<T, U> {
#[inline]
fn project_ref<'__pin>(
self: ::pin_project_lite::__private::Pin<&'__pin Self>,
) -> EnumProjRef<'__pin, T, U> {
Expand Down
3 changes: 3 additions & 0 deletions tests/expand/naming/struct-all.expanded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ struct StructProjReplace<T, U> {
#[allow(clippy::used_underscore_binding)]
const _: () = {
impl<T, U> Struct<T, U> {
#[inline]
fn project<'__pin>(
self: ::pin_project_lite::__private::Pin<&'__pin mut Self>,
) -> StructProj<'__pin, T, U> {
Expand All @@ -58,6 +59,7 @@ const _: () = {
}
}
}
#[inline]
fn project_ref<'__pin>(
self: ::pin_project_lite::__private::Pin<&'__pin Self>,
) -> StructProjRef<'__pin, T, U> {
Expand All @@ -69,6 +71,7 @@ const _: () = {
}
}
}
#[inline]
fn project_replace(
self: ::pin_project_lite::__private::Pin<&mut Self>,
replacement: Self,
Expand Down
2 changes: 2 additions & 0 deletions tests/expand/naming/struct-mut.expanded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const _: () = {
unpinned: &'__pin (U),
}
impl<T, U> Struct<T, U> {
#[inline]
fn project<'__pin>(
self: ::pin_project_lite::__private::Pin<&'__pin mut Self>,
) -> StructProj<'__pin, T, U> {
Expand All @@ -49,6 +50,7 @@ const _: () = {
}
}
}
#[inline]
fn project_ref<'__pin>(
self: ::pin_project_lite::__private::Pin<&'__pin Self>,
) -> ProjectionRef<'__pin, T, U> {
Expand Down
2 changes: 2 additions & 0 deletions tests/expand/naming/struct-none.expanded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const _: () = {
unpinned: &'__pin (U),
}
impl<T, U> Struct<T, U> {
#[inline]
fn project<'__pin>(
self: ::pin_project_lite::__private::Pin<&'__pin mut Self>,
) -> Projection<'__pin, T, U> {
Expand All @@ -49,6 +50,7 @@ const _: () = {
}
}
}
#[inline]
fn project_ref<'__pin>(
self: ::pin_project_lite::__private::Pin<&'__pin Self>,
) -> ProjectionRef<'__pin, T, U> {
Expand Down
2 changes: 2 additions & 0 deletions tests/expand/naming/struct-ref.expanded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const _: () = {
unpinned: &'__pin mut (U),
}
impl<T, U> Struct<T, U> {
#[inline]
fn project<'__pin>(
self: ::pin_project_lite::__private::Pin<&'__pin mut Self>,
) -> Projection<'__pin, T, U> {
Expand All @@ -49,6 +50,7 @@ const _: () = {
}
}
}
#[inline]
fn project_ref<'__pin>(
self: ::pin_project_lite::__private::Pin<&'__pin Self>,
) -> StructProjRef<'__pin, T, U> {
Expand Down
2 changes: 2 additions & 0 deletions tests/expand/pinned_drop/enum.expanded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ where
#[allow(clippy::used_underscore_binding)]
const _: () = {
impl<T, U> Enum<T, U> {
#[inline]
fn project<'__pin>(
self: ::pin_project_lite::__private::Pin<&'__pin mut Self>,
) -> EnumProj<'__pin, T, U> {
Expand All @@ -60,6 +61,7 @@ const _: () = {
}
}
}
#[inline]
fn project_ref<'__pin>(
self: ::pin_project_lite::__private::Pin<&'__pin Self>,
) -> EnumProjRef<'__pin, T, U> {
Expand Down
2 changes: 2 additions & 0 deletions tests/expand/pinned_drop/struct.expanded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const _: () = {
unpinned: &'__pin (U),
}
impl<T, U> Struct<T, U> {
#[inline]
fn project<'__pin>(
self: ::pin_project_lite::__private::Pin<&'__pin mut Self>,
) -> Projection<'__pin, T, U> {
Expand All @@ -50,6 +51,7 @@ const _: () = {
}
}
}
#[inline]
fn project_ref<'__pin>(
self: ::pin_project_lite::__private::Pin<&'__pin Self>,
) -> ProjectionRef<'__pin, T, U> {
Expand Down
2 changes: 2 additions & 0 deletions tests/expand/pub/enum.expanded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ where
#[allow(clippy::used_underscore_binding)]
const _: () = {
impl<T, U> Enum<T, U> {
#[inline]
pub(crate) fn project<'__pin>(
self: ::pin_project_lite::__private::Pin<&'__pin mut Self>,
) -> EnumProj<'__pin, T, U> {
Expand All @@ -59,6 +60,7 @@ const _: () = {
}
}
}
#[inline]
pub(crate) fn project_ref<'__pin>(
self: ::pin_project_lite::__private::Pin<&'__pin Self>,
) -> EnumProjRef<'__pin, T, U> {
Expand Down
2 changes: 2 additions & 0 deletions tests/expand/pub/struct.expanded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const _: () = {
pub unpinned: &'__pin (U),
}
impl<T, U> Struct<T, U> {
#[inline]
pub(crate) fn project<'__pin>(
self: ::pin_project_lite::__private::Pin<&'__pin mut Self>,
) -> Projection<'__pin, T, U> {
Expand All @@ -49,6 +50,7 @@ const _: () = {
}
}
}
#[inline]
pub(crate) fn project_ref<'__pin>(
self: ::pin_project_lite::__private::Pin<&'__pin Self>,
) -> ProjectionRef<'__pin, T, U> {
Expand Down

0 comments on commit 59f83eb

Please sign in to comment.