#[repr(i8)]pub enum Sign {
Negative = -1,
Zero = 0,
Positive = 1,
}Expand description
The sign of a real quantity.
The discriminants are -1, 0 and 1, so sign as i8 (or
i8::from(sign)) gives the usual integer sign, and signs are ordered as
those integers: Negative < Zero < Positive.
§Examples
use implicit_predicates_core::Sign;
assert_eq!(Sign::Negative as i8, -1);
assert_eq!(Sign::Zero as i8, 0);
assert_eq!(Sign::Positive as i8, 1);
assert!(Sign::Negative < Sign::Zero && Sign::Zero < Sign::Positive);Variants§
Negative = -1
Strictly less than zero.
Zero = 0
Exactly zero.
Positive = 1
Strictly greater than zero.
Implementations§
Source§impl Sign
impl Sign
Sourcepub fn of(x: f64) -> Sign
pub fn of(x: f64) -> Sign
Returns the sign of x. Both 0.0 and -0.0 give Sign::Zero.
NaN is not a valid input: debug builds panic on it, and release builds
return Sign::Zero, which is meaningless.
§Examples
use implicit_predicates_core::Sign;
assert_eq!(Sign::of(2.5), Sign::Positive);
assert_eq!(Sign::of(-2.5), Sign::Negative);
assert_eq!(Sign::of(-0.0), Sign::Zero);Sourcepub fn is_zero(self) -> bool
pub fn is_zero(self) -> bool
Returns true if the sign is Sign::Zero.
§Examples
use implicit_predicates_core::Sign;
assert!(Sign::Zero.is_zero());
assert!(!Sign::Positive.is_zero());Sourcepub fn is_positive(self) -> bool
pub fn is_positive(self) -> bool
Returns true if the sign is Sign::Positive.
§Examples
use implicit_predicates_core::Sign;
assert!(Sign::Positive.is_positive());
assert!(!Sign::Zero.is_positive());Sourcepub fn is_negative(self) -> bool
pub fn is_negative(self) -> bool
Returns true if the sign is Sign::Negative.
§Examples
use implicit_predicates_core::Sign;
assert!(Sign::Negative.is_negative());
assert!(!Sign::Zero.is_negative());Trait Implementations§
impl Copy for Sign
impl Eq for Sign
Source§impl Mul for Sign
impl Mul for Sign
Source§fn mul(self, rhs: Sign) -> Sign
fn mul(self, rhs: Sign) -> Sign
The sign of a product: zero if either factor is zero, positive if the signs agree, negative otherwise.
§Examples
use implicit_predicates_core::Sign;
assert_eq!(Sign::Negative * Sign::Negative, Sign::Positive);
assert_eq!(Sign::Negative * Sign::Positive, Sign::Negative);
assert_eq!(Sign::Zero * Sign::Positive, Sign::Zero);Source§impl Ord for Sign
impl Ord for Sign
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
Source§impl PartialOrd for Sign
impl PartialOrd for Sign
impl StructuralPartialEq for Sign
Auto Trait Implementations§
impl Forget for Sign
impl Freeze for Sign
impl Move for Sign
impl RefUnwindSafe for Sign
impl Send for Sign
impl Sync for Sign
impl Unpin for Sign
impl UnsafeUnpin 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