#[doc(hidden)]
#[macro_export]
macro_rules! __impl_unexpected_token {
() => {};
}
#[doc(hidden)]
#[macro_export]
macro_rules! __expand_or {
([]$($defaults:tt)*) => {
$($defaults)*
};
([$($t:tt)+]$($defaults:tt)*) => {
$($t)*
};
}
#[doc(hidden)]
#[macro_export]
macro_rules! __impl_fn_hook_body_finish_as_closure {
(
// options
[
$(append_args_pat! { $($append_args_pat:tt)+ })?
]
[$($args_pat:tt)*]
$body:tt
) => {
move |
$($args_pat)*
$(, $($append_args_pat)+ )?
| $body
};
}
#[doc(hidden)]
#[macro_export]
macro_rules! __impl_fn_hook_body_finish {
(
[
$options:tt
$rest_ids:tt
]
[] // used_ids
[$($transformed_code:tt)*]
) => {
$crate::__impl_fn_hook_body_finish_as_closure! {
$options
[_: ::core::pin::Pin<&mut $crate::HookTuple<()>>]
{ $($transformed_code)* }
}
};
(
[
$options:tt
$rest_ids:tt
]
[$used_id:ident] // used_ids
[$($transformed_code:tt)*]
) => {
$crate::__impl_fn_hook_body_finish_as_closure! {
$options
[$used_id : ::core::pin::Pin<&mut _>]
{ $($transformed_code)* }
}
};
(
[
$options:tt
$rest_ids:tt
]
[$($used_id:ident)+] // used_ids
[$($transformed_code:tt)*]
) => {
$crate::__impl_fn_hook_body_finish_as_closure! {
$options
[__hooks_hook_data: ::core::pin::Pin<&mut _>]
{
let ($($used_id,)+) = unsafe {
let $crate::HookTuple(($($used_id,)+)) = ::core::pin::Pin::get_unchecked_mut(__hooks_hook_data);
($(
::core::pin::Pin::new_unchecked($used_id),
)+)
};
$($transformed_code)*
}
}
};
}
#[doc(hidden)]
#[macro_export]
macro_rules! __impl_fn_hook_body_hook_resolved {
(
[$id:ident = $($e:tt)+]
$state:tt
[$($used_ids:ident)*]
$hook_ident:ident
[$($transformed_code:tt)*]
$code:tt
) => {
$crate::__impl_fn_hook_body! {
$state
[$($used_ids)* $id]
[
$($transformed_code)*
$crate::UpdateHookUninitialized::$hook_ident(
$($e)+,
$id
)
]
$code
$code
}
};
(
[$($e:tt)+]
[
$options:tt
[$id:ident $($rest_ids:ident)*]
]
[$($used_ids:ident)*]
$hook_ident:ident
[$($transformed_code:tt)*]
$code:tt
) => {
$crate::__impl_fn_hook_body! {
[
$options
[$($rest_ids)*]
]
[$($used_ids)* $id]
[
$($transformed_code)*
$crate::UpdateHookUninitialized::$hook_ident(
$($e)+,
$id
)
]
$code
$code
}
};
( ($($e:tt)*) $($other:tt)* ) => {
$crate::__impl_fn_hook_body_hook_resolved! { [$($e)*] $($other)* }
};
( {$($e:tt)*} $($other:tt)* ) => {
$crate::__impl_fn_hook_body_hook_resolved! { [$($e)*] $($other)* }
};
}
#[doc(hidden)]
#[macro_export]
macro_rules! __impl_fn_hook_body {
(
$state:tt
$used_ids:tt
$transformed_code:tt
{}{} // code is empty
) => {
$crate::__impl_fn_hook_body_finish! {
$state
$used_ids
$transformed_code
}
};
(
$state:tt $used_ids:tt $transformed_code:tt
{h ! $e:tt $($code:tt)*} { $hook_ident:ident ! $_e:tt $($_code:tt)* } // code
) => {
$crate::__impl_fn_hook_body_hook_resolved! {
$e
$state
$used_ids
$hook_ident
$transformed_code
{$($code)*} }
};
(
$state:tt $used_ids:tt [$($transformed_code:tt)*]
{$t0:tt h ! $e:tt $($code:tt)*} {$_t0:tt $hook_ident:ident ! $_e:tt $($_code:tt)* } // code
) => {
$crate::__impl_fn_hook_body_hook_resolved! {
$e
$state
$used_ids
$hook_ident
[$($transformed_code)* $t0]
{$($code)*} }
};
(
$state:tt $used_ids:tt [$($transformed_code:tt)*]
{$t0:tt $t1:tt h ! $e:tt $($code:tt)*} {$_t0:tt $_t1:tt $hook_ident:ident ! $_e:tt $($_code:tt)* } // code
) => {
$crate::__impl_fn_hook_body_hook_resolved! {
$e
$state
$used_ids
$hook_ident
[$($transformed_code)* $t0 $t1]
{$($code)*} }
};
(
$state:tt $used_ids:tt [$($transformed_code:tt)*]
{$t0:tt $t1:tt $t2:tt h ! $e:tt $($code:tt)*} {$_t0:tt $_t1:tt $_t2:tt $hook_ident:ident ! $_e:tt $($_code:tt)* } // code
) => {
$crate::__impl_fn_hook_body_hook_resolved! {
$e
$state
$used_ids
$hook_ident
[$($transformed_code)* $t0 $t1 $t2]
{$($code)*} }
};
(
$state:tt $used_ids:tt
[$($transformed_code:tt)*]
{$t0:tt $t1:tt $t2:tt $t3:tt $($code:tt)*} $_code:tt // code
) => {
$crate::__impl_fn_hook_body! {
$state $used_ids
[$($transformed_code)* $t0 $t1 $t2 $t3]
{$($code)*} {$($code)*}
}
};
(
$state:tt $used_ids:tt
[$($transformed_code:tt)*]
{$t0:tt $t1:tt $t2:tt $($code:tt)*} $_code:tt // code
) => {
$crate::__impl_fn_hook_body! {
$state $used_ids
[$($transformed_code)* $t0 $t1 $t2]
{$($code)*} {$($code)*}
}
};
(
$state:tt $used_ids:tt
[$($transformed_code:tt)*]
{$t0:tt $t1:tt $($code:tt)*} $_code:tt // code
) => {
$crate::__impl_fn_hook_body! {
$state $used_ids
[$($transformed_code)* $t0 $t1]
{$($code)*} {$($code)*}
}
};
(
$state:tt $used_ids:tt
[$($transformed_code:tt)*]
{$t0:tt $($code:tt)*} $_code:tt // code
) => {
$crate::__impl_fn_hook_body! {
$state $used_ids
[$($transformed_code)* $t0]
{$($code)*} {$($code)*}
}
};
}
#[doc(hidden)]
#[macro_export]
macro_rules! __impl_hook_fn_bounds_resolved {
($hook_bounds:tt #[hook $(($($options:tt)*))? ] $($rest:tt)*) => {
$crate::__private::parse_item_fn! {
on_finish { $crate::__impl_hook_fn_item_fn_parsed! }
prepend { $hook_bounds ($($($options)*)?) }
input {$($rest)*}
}
};
($hook_bounds:tt $($rest:tt)*) => {
$crate::__private::parse_item_fn! {
on_finish { $crate::__impl_hook_fn_item_fn_parsed! }
prepend {$hook_bounds ()}
input {$($rest)*}
}
};
}
#[doc(hidden)]
#[macro_export]
macro_rules! __impl_capture_lifetimes {
(
[$($prepend:tt)*]
{}
) => {
$($prepend)*
};
(
[$($prepend:tt)*]
{ $hook_bound:lifetime $(+)? }
) => {
$($prepend)*
+ $crate::Captures<
& $hook_bound ()
>
};
(
[$($prepend:tt)*]
{ $hook_bound:lifetime $(+ $hook_bounds:lifetime)+ $(+)? }
) => {
$($prepend)*
+ $crate::Captures<(
& $hook_bound (),
$(& $hook_bounds (),)+
)>
};
}
#[doc(hidden)]
#[macro_export]
macro_rules! __impl_hook_fn_item_fn_parsed {
(
$hook_bounds:tt
$method_path:tt
item_fn {
$(outer_attrs $outer_attrs:tt)?
vis $vis:tt
sig $sig:tt
block { $fn_body:tt }
}
rest {}
) => {
$crate::__private::consume_inner_attrs! {
on_finish {$crate::__impl_hook_fn_item_fn_body_parsed!}
prepend {
$hook_bounds
$method_path
item_fn {
$(outer_attrs $outer_attrs)?
vis $vis
sig $sig
}
}
input $fn_body
}
};
}
#[doc(hidden)]
#[macro_export]
macro_rules! __impl_hook_fn_item_fn_body_parsed {
(
{ $($hook_bounds:tt)* } // { 'a + 'b }
($($method_path:ident),* $(,)?)
item_fn {
$(outer_attrs { $($outer_attrs:tt)* })?
vis { $vis:vis }
sig {
fn { $fn:tt }
ident { $name:ident }
$(
lt {<}
parsed_generics {
generics { $($generic_params:tt)* }
impl_generics $impl_generics:tt
type_generics { $($type_generics:tt)* }
generics_info $generics_info:tt
}
gt {>}
)?
paren_inputs { $paren_inputs:tt }
output { $(-> $ret_ty:ty)? }
$(where_clause { $($where_clause:tt)* })?
}
}
inner_attrs { $($inner_attrs:tt)* }
rest { $($stmts:tt)* }
) => {
$($($outer_attrs)*)?
$vis fn $name
<$($($generic_params)*)?>
$paren_inputs
-> $crate::UpdateHookUninitialized![
@ extract_lifetimes_from_generics {
value! { $crate::__private::expand_or![[$($ret_ty)?]()] }
$(generics_info! $generics_info)?
bounds! { $($hook_bounds)* }
}
]
$($where_clause)*
{
$($inner_attrs)*
#[allow(unused_imports)]
use $crate::prelude_h::*;
enum __HooksImplNever {}
struct __HooksValueOfThisHook <$($($generic_params)*)?>
$($where_clause)*
{
__: (__HooksImplNever, $($crate::__impl_phantoms! $generics_info)?)
}
impl<
'hook,
$($($generic_params)*)?
> $crate::HookValue<'hook> for __HooksValueOfThisHook <$($($type_generics)*)?>
$($where_clause)*
{
type Value = $crate::__private::expand_or![[$($ret_ty)?]()];
}
$crate::fn_hook::use_fn_hook $(::$method_path)*
::<
__HooksValueOfThisHook <$($($type_generics)*)?>
, _, _
>
(
$crate::transform_hook_fn_body_as_closure!(
[]
{$($stmts)*}
)
)
}
};
}
#[doc(hidden)]
#[macro_export]
macro_rules! __impl_hook_method_poll_next_update {
(
$(#$fn_attr:tt)*
$fn_name:ident () $fn_body:tt
) => {
$crate::__impl_hook_method_poll_next_update! {
$(#$fn_attr)*
$fn_name (self, _: _) $fn_body
}
};
(
$(#$fn_attr:tt)*
$fn_name:ident (
$self0:ident
$($self1:ident)?
$(,)?
) $fn_body:tt
) => {
$crate::__impl_hook_method_poll_next_update! {
$(#$fn_attr)*
$fn_name ($self0 $($self1)?, _: _) $fn_body
}
};
(
$(#$fn_attr:tt)*
$fn_name:ident (
$self0:ident
$($self1:ident)?,
$cx_pat:tt : _ $(,)?
) $fn_body:tt
) => {
$(#$fn_attr)*
fn $fn_name(
$self0 $($self1)? : ::core::pin::Pin<&mut Self>,
$cx_pat: &mut ::core::task::Context<'_>,
) -> ::core::task::Poll<bool> $fn_body
};
}
#[doc(hidden)]
#[macro_export]
macro_rules! __impl_trait_hook_unmount {
(
([$($generics:tt)*][$ty:ty][$( $($where_clause:tt)+ )?])[
$(#$fn_attr:tt)*
$fn_name:ident
($($args:tt)*)
{}
]
) => {
$crate::__impl_unexpected_token! { $($args)* }
$(#$fn_attr)*
impl<$($generics)*> $crate::HookUnmount for $ty $(where $($where_clause)*)? {}
};
(
([$($generics:tt)*][$ty:ty][$( $($where_clause:tt)+ )?])[
$(#$fn_attr:tt)*
$fn_name:ident
( $($self_arg:ident)+ $(,)? )
$fn_body:tt
]
) => {
impl<$($generics)*> $crate::HookUnmount for $ty $(where $($where_clause)*)? {
$(#$fn_attr)*
fn $fn_name(
$($self_arg)+ : ::core::pin::Pin<&mut Self>
) $fn_body
}
};
}
#[doc(hidden)]
#[macro_export]
macro_rules! __impl_hook_with_method {
(
poll_next_update([$($generics:tt)*][$ty:ty][$( $($where_clause:tt)+ )?]) $fn_data:tt
) => {
impl<$($generics)*> $crate::HookPollNextUpdate for $ty $(where $($where_clause)*)? {
$crate::__impl_hook_method_poll_next_update! $fn_data ;
}
};
(
unmount $types:tt $fn_data:tt
) => {
$crate::__impl_trait_hook_unmount! {
$types $fn_data
}
};
(
use_hook([$($generics:tt)*][$ty:ty][$( $($where_clause:tt)+ )?])[
$(#$fn_attr:tt)*
$fn_name:ident
($self0:ident $($self1:ident)? $(,)?)
$(-> $ret_ty:ty)?
{
$($fn_body:tt)*
}
]
) => {
impl<'hook, $($generics)*> $crate::HookValue<'hook> for $ty $(where $($where_clause)*)? {
type Value = $crate::__expand_or![
[$($ret_ty)?]
()
];
}
impl<$($generics)*> $crate::Hook for $ty $(where $($where_clause)*)? {
$(#$fn_attr)*
fn $fn_name(
$self0 $($self1)? : ::core::pin::Pin<&mut Self>
) -> <Self as $crate::HookValue<'_>>::Value
{$($fn_body)*}
}
};
(
into_hook([$($generics:tt)*][$ty:ty][$( $($where_clause:tt)+ )?])[
$(#$fn_attr:tt)*
$fn_name:ident
($self0:ident $($self1:ident)?)
-> $hook_ty:ty
{$($fn_body:tt)*}
]
) => {
impl<$($generics)*> $crate::IntoHook for $ty $(where $($where_clause)*)? {
type Hook = $hook_ty;
$(#$fn_attr)*
fn $fn_name(
$self0 $($self1)?
) -> Self::Hook
{$($fn_body)*}
}
};
(
update_hook([$($generics:tt)*][$ty:ty][$( $($where_clause:tt)+ )?])[
$(#$fn_attr:tt)*
$fn_name:ident
($self0:ident $($self1:ident)?, $hook0:ident $($hook1:ident)? : _ $(,)?)
$fn_body:tt
]
) => {
impl<$($generics)*> $crate::UpdateHook for $ty $(where $($where_clause)*)? {
$(#$fn_attr)*
fn $fn_name(
$self0 $($self1)?,
$hook0 $($hook1)? : ::core::pin::Pin<&mut Self::Hook>,
) $fn_body
}
};
(
h([$($generics:tt)*][$ty:ty][$( $($where_clause:tt)+ )?])[
$(#$fn_attr:tt)*
$fn_name:ident
($self0:ident $($self1:ident)?, $hook0:ident $($hook1:ident)? : $ty_uninitialized:ty)
$(-> $explicit_value:ty)?
{$($fn_body:tt)*}
]
) => {
impl<$($generics)*> $crate::UpdateHookUninitialized for $ty $(where $($where_clause)*)? {
type Uninitialized = $ty_uninitialized;
$(#$fn_attr)*
fn $fn_name(
$self0 $($self1)?,
$hook0 $($hook1)? : ::core::pin::Pin<&mut Self::Uninitialized>,
) -> $crate::__expand_or![
[$($explicit_value)?]
<Self::Hook as $crate::HookValue<'_>>::Value
]
{$($fn_body)*}
}
};
}
#[doc(hidden)]
#[macro_export]
macro_rules! __impl_hook_methods {
(
$data:tt
$(
$fn_name:ident
$fn_data:tt
)*
) => {$(
$crate::__impl_hook_with_method! {
$fn_name
$data
$fn_data
}
)*};
}
#[doc(hidden)]
#[macro_export]
macro_rules! __impl_phantoms {
(
$($generics_info:tt)*
) => {
($(
$crate::__impl_phantom! $generics_info,
)*)
};
}
#[doc(hidden)]
#[macro_export]
macro_rules! __impl_phantom {
(
$(lifetime_attrs $attrs:tt)?
lifetime {$lt:lifetime}
$($rest:tt)*
) => {
::core::marker::PhantomData::<&$lt()>
};
(
$(const_attrs $attrs:tt)?
const {const}
name {$name:ident}
$($rest:tt)*
) => {
()
};
(
$(type_attrs $attrs:tt)?
name {$tp:ident}
$($rest:tt)*
) => {
::core::marker::PhantomData::<$tp>
};
}
#[doc(hidden)]
#[macro_export]
macro_rules! __impl_impl_hook {
(
generic_params $generic_params:tt
for_ty $for_ty:tt
$(where_clause $where_clause:tt)?
rest { $body:tt }
) => {
$crate::__impl_impl_hook! {
generic_params $generic_params
for_ty $for_ty
$(where_clause $where_clause)?
body $body
}
};
(
generic_params { $($generic_params:tt)* }
for_ty { $ty:ty }
$(where_clause { $( where $($where_clause:tt)*)? })?
body {
$(
$(#$fn_attr:tt)*
fn $fn_name:ident $args:tt $(-> $fn_ret_ty:ty)?
{$($impl_hook:tt)*}
)*
}
) => {
$crate::__impl_hook_methods! {
(
[$($generic_params)*]
[$ty]
[$($($($where_clause)*)?)?]
)
$(
$fn_name [
$(#$fn_attr)*
$fn_name $args $(-> $fn_ret_ty)?
{$($impl_hook)*}
]
)*
}
};
}
#[doc(hidden)]
#[macro_export]
macro_rules! __impl_impl_hook_generics_consumed {
(
before_gt $before_gt:tt
gt_and_rest {
> $ty:ty {
$($rest:tt)*
}
}
) => {
$crate::__impl_impl_hook! {
generic_params $before_gt
for_ty { $ty }
body { $($rest)* }
}
};
(
before_gt $before_gt:tt
gt_and_rest {
> $ty:ty
where $($rest:tt)*
}
) => {
$crate::__private::consume_optional_where_clause! {
on_finish {$crate::__impl_impl_hook!}
prepend {
generic_params $before_gt
for_ty { $ty }
}
input { where $($rest)* }
}
};
}
#[doc(hidden)]
#[macro_export]
macro_rules! __impl_pin_project_hook_tuple {
($hook_tuple:ident, $($used_id:ident),+ $(,)?) => {
let ($($used_id,)+) = unsafe {
let $crate::HookTuple(($($used_id,)+)) = ::core::pin::Pin::get_unchecked_mut($hook_tuple);
($(
::core::pin::Pin::new_unchecked($used_id),
)+)
};
};
}