You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is there any neat way to check if a primitive integer is even or odd? Currently I would imagine either some casts or some bit-wise manipulations on the generic type PrimInt is needed and it would obfuscate code readibility. For example, if we used the modulo way:
fnsome_func<T>(n:T) -> boolwhereT:PrimInt + FromPrimitive,{// Do something else...
n % T::from_usize(2).unwrap() == T::zero()}
versus something like
fnsome_func<T>(n:T) -> boolwhereT:PrimInt + FromPrimitive,{// Do something else...
n.is_even()}
Thoughts? I could work on a PR if this would be appreciated.
The text was updated successfully, but these errors were encountered:
Is there any neat way to check if a primitive integer is even or odd? Currently I would imagine either some casts or some bit-wise manipulations on the generic type PrimInt is needed and it would obfuscate code readibility. For example, if we used the modulo way:
versus something like
Thoughts? I could work on a PR if this would be appreciated.
The text was updated successfully, but these errors were encountered: