Tool rusties compound

struct Foo {
    count: u32

impl Iterator for Foo {
    type Item = u32;
    fn next(&mut self) -> Option<Self::Item> {
        if self.count > 0 {
            self.count -= 1;
        } else {

fn main() {
    let foo = Foo { count: 5 };
    for num in foo {
        println!("Count: {}", num);


What is your question?

1 Like

Hi and welcome to the Rust users forum. It looks like you have found the option to share code from the rust Playground here. Usually, you should use this with some code you wrote yourself and have questions about or need help with. If you do so, also make sure to add a problem description or question to your post.

Like this there is no problematic code and no question for anyone to react to. Feel free to come back to this forum with any actual problem or question you have and can't easily find the answer to. Meanwhile, have fun with the Rust programming language - cheers :slight_smile:


This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.