pub enum Sign {
Positive = 1,
Negative = -1,
}
Variants§
Implementations§
Source§impl Sign
impl Sign
pub fn to_isize(self) -> isize
pub fn to_i64(self) -> i64
pub fn to_i32(self) -> i32
pub fn to_i16(self) -> i16
pub fn to_i8(self) -> i16
Sourcepub fn parity(n: impl Into<i32>) -> Self
pub fn parity(n: impl Into<i32>) -> Self
(-1)^n (i.e. if n % 2 == 0 { Positive } else { Negative }
)
use num_sign::*;
assert_eq!(Sign::parity(0), Positive);
assert_eq!(Sign::parity(7), Negative);
assert_eq!(Sign::parity(-2), Positive);
assert_eq!(Sign::parity(false), Positive);
assert_eq!(Sign::parity(true), Negative);
Trait Implementations§
Source§impl Ord for Sign
impl Ord for Sign
Source§impl PartialOrd for Sign
impl PartialOrd for Sign
impl Copy for Sign
impl Eq for Sign
impl StructuralPartialEq for Sign
Auto Trait Implementations§
impl Freeze for Sign
impl RefUnwindSafe for Sign
impl Send for Sign
impl Sync for Sign
impl Unpin for Sign
impl UnwindSafe for Sign
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more