The following does not compile because the two iterators have different signatures. But, both iterators return the same item type and conceptually behave the same.
fn f(flag: bool) -> impl Iterator<Item = u8> {
if flag {
(0..8).into_iter()
} else {
(0..8).into_iter().map(|x| x + 1)
}
}
I want to write a function that returns items generated from different variants of an algorithm, selected by values I pass into the function. How can I achieve this?
Ultimately, I need to use this in a no_std environment. Is this possible?