Closed
Description
Currently CUSTOM_START
sets the two upper-most bits in the u32, however it is not obvious and documented how many codes are available above this point. For instance, doing something along the lines:
const MY_LIBRARY_BIT: u32 = 1 << 31;
pub const SOME_ERROR: NonZeroU32 = unsafe {
NonZeroU32::new_unchecked(rand_core::CUSTOM_START + MY_LIBRARY_BIT + 1)
};
will fail to compile because of the addition overflow. If the user were to use bitwise or, the error would become silent, but it isn’t clear whether that’s desirable.
The documentation for CUSTOM_START
should document the range of values users can expect to use within the u32.