fn_traits/fns/
poll_ready_fn.rs1use crate::{Fn, FnMut, FnOnce};
2use core::marker::PhantomData;
3use core::task::Poll;
4
5#[derive(Clone, Copy, Default)]
7pub struct PollReadyFn {
8 _phantom: PhantomData<()>,
9}
10
11impl<T> FnOnce<(T,)> for PollReadyFn {
12 type Output = Poll<T>;
13
14 fn call_once(self, args: (T,)) -> Self::Output {
15 Poll::Ready(args.0)
16 }
17}
18
19impl<T> FnMut<(T,)> for PollReadyFn {
20 type Output = Poll<T>;
21
22 fn call_mut(&mut self, args: (T,)) -> Self::Output {
23 self.call_once(args)
24 }
25}
26
27impl<T> Fn<(T,)> for PollReadyFn {
28 type Output = Poll<T>;
29
30 fn call(&self, args: (T,)) -> Self::Output {
31 self.call_once(args)
32 }
33}
34
35#[cfg(test)]
36mod tests {
37 use super::super::tests::{into_std_fn, into_std_fn_mut, into_std_fn_once};
38 use super::PollReadyFn;
39 use core::task::Poll;
40
41 #[test]
42 fn test_poll_ready_fn() {
43 let f = PollReadyFn::default();
44
45 assert_eq!(into_std_fn_once(Clone::clone(&f))(2), Poll::Ready(2));
46 assert_eq!(into_std_fn_mut(Clone::clone(&f))(2), Poll::Ready(2));
47 assert_eq!(into_std_fn(Clone::clone(&f))(2), Poll::Ready(2));
48 }
49}