Ad
  • Custom User Avatar

    Just copy the struct and create the simple methods for creating the children nodes.

    Something like this:

    struct Node {
        value: u32,
        left: Option<Box<Node>>,
        right: Option<Box<Node>>,
    }
    
    impl Node {
        fn new(value: u32) -> Self {
            Node {
                value,
                left: None,
                right: None,
            }
        }
    
        fn left(mut self, node: Node) -> Node {
            self.left = Some(Box::new(node));
            self
        }
    
        fn right(mut self, node: Node) -> Node {
            self.right = Some(Box::new(node));
    
            self
        }
    }
    
  • Custom User Avatar

    How am i supposed to import this "preloaded" module from rust into my working ide? I can't find it anywhere.

  • Custom User Avatar

    Thanks! It's my first test here, it works now.

  • Custom User Avatar

    You must return the result, not print it.

  • Custom User Avatar

    Ok, for some reason, the output taken by answer is "None: None" instead of my code output. As follow:

    Test Results:
    Log
    There are 17 in total.
    There are 17 sheeps in total, not None: None should equal 17
    Log
    There are 500 in total.
    There are 500 sheeps in total, not None: None should equal 500
    Log
    There are 0 in total.
    There are no sheeps at all, you counted None: None should equal 0