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

@ -1,3 +1,4 @@
#[allow(dead_code)]
fn climb_stairs_on2(n: i32) -> i32 { fn climb_stairs_on2(n: i32) -> i32 {
if n == 1 { if n == 1 {
return 1; return 1;

View file

@ -35,6 +35,34 @@ impl Solution {
} }
} }
fn main() { fn test_max_depth() {
println!("Hello, world!"); 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());
} }

View file

@ -11,6 +11,7 @@ pub struct ListNode {
impl ListNode { impl ListNode {
#[inline] #[inline]
#[allow(dead_code)]
fn new(val: i32) -> Self { fn new(val: i32) -> Self {
ListNode { next: None, val } ListNode { next: None, val }
} }