≈ the.bay.news

Make NonZero usable as Const param

Rust Internals
Make NonZero usable as Const param
This could be useful for types which check if their Const param is 0. For example consider this arena: struct Arena<const CAP: usize> { ptr: *mut u8, pos: usize, } In its constructor you would have to check its size and panic! if its zero. It would for most people be cleaner if the Const param showed that only non-zero values are allowed. Ideally you could fill in a number literal for the param and the compiler would check if it 0 instead of filling it in with NonNull::new().unwrap() ...

0 comments

Sign in to join the discussion — your thebay.events account works here.

No comments yet.