1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
use std::{pin::Pin, task::Poll};
use crate::{Hook, HookLifetime, HookPollNextUpdate};
use super::NextUpdate;
pub trait HookPollNextUpdateExt: HookPollNextUpdate {
#[inline]
fn poll_next_update(&mut self, cx: &mut std::task::Context<'_>) -> Poll<bool>
where
Self: Unpin,
{
HookPollNextUpdate::poll_next_update(Pin::new(self), cx)
}
#[inline]
fn next_update(&mut self) -> NextUpdate<'_, Self>
where
Self: Unpin,
{
NextUpdate::new(self)
}
}
impl<H: HookPollNextUpdate + ?Sized> HookPollNextUpdateExt for H {}
pub trait HookExt<Args>: Hook<Args> {
#[inline]
fn use_hook(&mut self, args: Args) -> <Self as HookLifetime<'_, Args>>::Value
where
Self: Unpin,
{
<Self as Hook<Args>>::use_hook(Pin::new(self), args)
}
#[inline]
fn next_value(&mut self, args: Args) -> crate::NextValue<'_, Self, Args>
where
Self: Unpin,
{
crate::NextValue::new(Pin::new(self), args)
}
#[inline]
fn next_value_with<F: FnOnce(Pin<&mut Self>) -> Args>(
&mut self,
get_args: F,
) -> crate::NextValueWith<'_, Self, Args, F>
where
Self: Unpin,
{
crate::NextValueWith::new(Pin::new(self), get_args)
}
#[inline]
fn next_value_with_default_args(&mut self) -> crate::NextValueWithDefaultArgs<'_, Self, Args>
where
Self: Unpin,
Args: Default,
{
crate::NextValueWithDefaultArgs::new(Pin::new(self))
}
}
impl<Args, H: Hook<Args> + ?Sized> HookExt<Args> for H {}