In the section References Are Never Null in the book Programming Rust, they point out there's no analogue to C's NULL
. That bit I understand. They then state
Rust won't convert integers to references (outside of
unsafe
code), so you can't convert zero into a reference.
Does this statement correspond to Rust code that won't compile? What is that code?
Note this compiles fine
let i = 0;
let ri = &i;
println!("{}", i);
println!("{}", ri);
so they're presumably not talking about that.
Note: I think my original question was largely answered by Why is address zero used for the null pointer?