1use crate::DynPtr;
2use core::{
3 future::Future,
4 iter::FusedIterator,
5 pin::Pin,
6 task::{Context, Poll},
7};
8
9impl<F: ?Sized + Future + Unpin> Future for DynPtr<F> {
10 type Output = F::Output;
11
12 fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
13 Pin::new(&mut **self).poll(cx)
14 }
15}
16
17impl<I: Iterator + ?Sized> Iterator for DynPtr<I> {
18 type Item = I::Item;
19 fn next(&mut self) -> Option<I::Item> {
20 (**self).next()
21 }
22 fn size_hint(&self) -> (usize, Option<usize>) {
23 (**self).size_hint()
24 }
25 fn last(self) -> Option<I::Item> {
26 #[inline]
27 fn some<T>(_: Option<T>, x: T) -> Option<T> {
28 Some(x)
29 }
30
31 self.fold(None, some)
32 }
33 fn nth(&mut self, n: usize) -> Option<I::Item> {
34 (**self).nth(n)
35 }
36}
37
38impl<I: DoubleEndedIterator + ?Sized> DoubleEndedIterator for DynPtr<I> {
39 fn next_back(&mut self) -> Option<I::Item> {
40 (**self).next_back()
41 }
42 fn nth_back(&mut self, n: usize) -> Option<I::Item> {
43 (**self).nth_back(n)
44 }
45}
46
47impl<I: ExactSizeIterator + ?Sized> ExactSizeIterator for DynPtr<I> {
48 fn len(&self) -> usize {
49 (**self).len()
50 }
51 fn is_empty(&self) -> bool {
52 (**self).is_empty()
53 }
54}
55
56impl<I: FusedIterator + ?Sized> FusedIterator for DynPtr<I> {}