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()
}
}