Null pointers


#1

There are 58 instances of 0 as * in the Rust source code. There are 202 instances of ptr::null in the Rust source code.

Since 0 as *const _ or 0 as *mut _ looks uglier and is used less often, I therefore propose to always use ptr::null() or ptr::null_mut() whenever possible in the Rust source code.

A point was brought up that 0 as * is needed for constants and statics, to which I reply with eddyb’s RFC 911.

Another point was brought up that ptr::null requires ptr to be in scope, to which I reply stop being lazy and use ptr;.

Commence the bikeshedding.


#2

Note that the statistics may be a bit biased due to a semi-recent PR, and there wasn’t much discussion on that PR as well.