Open
Description
It would be nice if there was some way to express things like this.
// There is `ZeroablePrimitive` but that is an unstable and internal trait.
struct Example<U: PrimInt> {
nz: NonZero<U>,
val: U
}
I don't see anything really in the num_traits
for working with NonZero or knowing that the type can be made into one.
// I ended up doing something like this:
struct Example<U: PrimInt + NonZeroType> {
nz: U::NonZero,
val: U
}
// However this leaves a lot traits and other features of NonZero not available
// short of adding more to this trait
pub trait NonZeroType: PrimInt {
type NonZero;
fn new(self) -> Option<Self::NonZero>;
unsafe fn new_unchecked(self) -> Self::NonZero;
fn get(nz: Self::NonZero) -> Self;
}
Metadata
Metadata
Assignees
Labels
No labels