rune_alloc/iter/
try_cloned.rs
1use crate::clone::TryClone;
2use crate::error::Error;
3
4pub struct TryCloned<I> {
12 it: I,
13}
14
15impl<I> TryCloned<I> {
16 pub(in crate::iter) fn new(it: I) -> Self {
17 Self { it }
18 }
19}
20
21impl<'a, I, T: 'a> Iterator for TryCloned<I>
22where
23 I: Iterator<Item = &'a T>,
24 T: TryClone,
25{
26 type Item = Result<T, Error>;
27
28 #[inline]
29 fn next(&mut self) -> Option<Self::Item> {
30 Some(self.it.next()?.try_clone())
31 }
32
33 fn size_hint(&self) -> (usize, Option<usize>) {
34 self.it.size_hint()
35 }
36}