summaryrefslogtreecommitdiff
path: root/meap/meap-code/ch10/ch10-callstack/src/main.rs
blob: cbb56e36fb5af0f1c55c9990bcec60f8ddc609f3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
fn print_depth(depth:usize) {
    for _ in 0..depth {
        print!("#");
    }
    println!("");
}

fn dive(depth: usize, max_depth: usize) {
    print_depth(depth);
    if depth >= max_depth {
        return;

    } else {
        dive(depth+1, max_depth);
    }
    print_depth(depth);
}

fn main() {
    dive(0, 5);
}