Ignorer lints som ikke trengs

This commit is contained in:
Håkon Størdal 2025-03-25 17:22:37 +01:00
parent c09ac53fef
commit d06e49bcd7
3 changed files with 32 additions and 2 deletions

View file

@ -35,6 +35,34 @@ impl Solution {
}
}
fn main() {
println!("Hello, world!");
fn test_max_depth() {
use std::cell::RefCell;
use std::rc::Rc;
// Helper function to create a TreeNode
fn new_node(
val: i32,
left: Option<Rc<RefCell<TreeNode>>>,
right: Option<Rc<RefCell<TreeNode>>>,
) -> Option<Rc<RefCell<TreeNode>>> {
Some(Rc::new(RefCell::new(TreeNode { val, left, right })))
}
// Constructing a simple tree:
// 1
// / \
// 2 3
// /
// 4
let tree = new_node(
1,
new_node(2, new_node(4, None, None), None),
new_node(3, None, None),
);
assert_eq!(Solution::max_depth(tree), 3);
}
fn main() {
println!("{:?}", test_max_depth());
}