3 ms·
Well, while Rust does have pointer types[1], it doesn't allow them to be used in typical code (i.e. dereferenced), except within "unsafe" blocks. A null pointer
by eatbitseveryday 10y ago
Well, while Rust does have pointer types[1], it doesn't allow them to be used in typical code (i.e. dereferenced), except within "unsafe" blocks. A null pointer does exist[2]. I believe this is needed for such things as interoperability with C code.
[1] https://doc.rust-lang.org/std/primitive.pointer.html https://doc.rust-lang.org/std/primitive.pointer.html
[2] https://doc.rust-lang.org/std/ptr/fn.null.html https://doc.rust-lang.org/std/ptr/fn.null.html
- brobinson 10y agoThe only use case I've had for these personally is having a global config "constant" which can be reloaded behind a mutex. unsafe + Box::new() + mem::transmute() on a static mutable pointer. I believe I copied this from Servo based on a suggestion on IRC. IIRC this was pre-1.0 Rust, so there's probably a better way to do it now.