Closed gliderkite closed 8 months ago
NonZero so badly integrated into Rust. Are there are compile time/const traits which help with that? Tbh only when NZ will have CONST into it would be awesome.
Thanks for the interest.
I do not plan to make truncate
accept non zero for two reasons:
in many cases it just moves the non-zero check out of the function, but also no longer yields a Size0Error
doing so works for truncate
but not other functions (e.g. pop
) so making truncate
fallible is more in line with the rest of the API
Through is will add a variant of the function (and potential other functions, I will have to check) which does accept NonZeroUsize
.
I added truncate_nonzero
and some similar methods in the last release.
Vec1::truncate returns an error if the specified
len: usize
is 0. This could be avoided by having NonZeroUsize instead as input (breaking change).