How a function call reserves a stack frame, fills it in, and hands a value back to its caller
The compiled program has been loaded into memory, but no function has run yet. Nothing is on the stack and nothing is on the heap
1fn main() {2 let x = 5;3 let result = foo(x);4 println!("{result}");5}67fn foo(input: i32) -> i32 {8 let y = input + 2;9 y * 310}How a function call reserves a stack frame, fills it in, and hands a value back to its caller
foo entirelystd::thread get a 2 MiB stack by default, while the main thread's size is set by the OS (commonly 8 MiB on Linux)$cargorun// waiting for the first println!