Description of the problem:
In the section "Boxes Live in the Heap", the diagrams show a code snippet:
let a = [0; 1_000_000];
let b = a;
and later
let a = Box::new([0; 1_000_000]);
let b = a;
which is also talked about much more in the chapter. This code causes a stack overflow for both the stack-based array version and box-based heap version because the rust compiler actually copies a stack based array and moves it into the heap (https://doc.rust-lang.org/beta/alloc/boxed/index.html#examples). There is no warning about this or Ferris image to indicate to the reader that this code doesn't actually work, and since neither the compiler nor rust-analyzer warns about this either, I think it would be beneficial to include it in the chapter itself.
Suggested fix:
Either add a Ferris image for "This code panics!", write a "Note:" section explaining this, or change the values in the array to be under the smallest default stack size across operating systems (512kib on mac iirc). I understand this is kind of a nit-picky issue but new readers who are following the book interactively and are met with a runtime error will be very confused.
main
branch to see if this has already been fixed, in this file:URL to the section(s) of the book with this problem: https://rust-book.cs.brown.edu/ch04-01-what-is-ownership.html
Description of the problem: In the section "Boxes Live in the Heap", the diagrams show a code snippet:
and later
which is also talked about much more in the chapter. This code causes a stack overflow for both the stack-based array version and box-based heap version because the rust compiler actually copies a stack based array and moves it into the heap (https://doc.rust-lang.org/beta/alloc/boxed/index.html#examples). There is no warning about this or Ferris image to indicate to the reader that this code doesn't actually work, and since neither the compiler nor rust-analyzer warns about this either, I think it would be beneficial to include it in the chapter itself.
Suggested fix: Either add a Ferris image for "This code panics!", write a "Note:" section explaining this, or change the values in the array to be under the smallest default stack size across operating systems (512kib on mac iirc). I understand this is kind of a nit-picky issue but new readers who are following the book interactively and are met with a runtime error will be very confused.