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
use crate::protocol::Breadcrumb;
pub trait IntoBreadcrumbs {
type Output: Iterator<Item = Breadcrumb>;
fn into_breadcrumbs(self) -> Self::Output;
}
impl IntoBreadcrumbs for Breadcrumb {
type Output = std::iter::Once<Breadcrumb>;
fn into_breadcrumbs(self) -> Self::Output {
std::iter::once(self)
}
}
impl IntoBreadcrumbs for Vec<Breadcrumb> {
type Output = std::vec::IntoIter<Breadcrumb>;
fn into_breadcrumbs(self) -> Self::Output {
self.into_iter()
}
}
impl IntoBreadcrumbs for Option<Breadcrumb> {
type Output = std::option::IntoIter<Breadcrumb>;
fn into_breadcrumbs(self) -> Self::Output {
self.into_iter()
}
}
impl<F: FnOnce() -> I, I: IntoBreadcrumbs> IntoBreadcrumbs for F {
type Output = I::Output;
fn into_breadcrumbs(self) -> Self::Output {
self().into_breadcrumbs()
}
}