Hard
Two Iterator impls for one type with different Item types
What happens when this program is compiled?
main.rs
struct Counter {
count: i32,
}
impl Iterator for Counter {
type Item = i32;
fn next(&mut self) -> Option<i32> {
self.count += 1;
Some(self.count)
}
}
impl Iterator for Counter {
type Item = String;
fn next(&mut self) -> Option<String> {
self.count += 1;
Some(self.count.to_string())
}
}
fn main() {
let mut c = Counter { count: 0 };
println!("{:?}", c.next());
}19 of 53 in Rust