pub trait Signed {
// Required method
fn sign(&self) -> Sign;
// Provided methods
fn is_positive(&self) -> bool { ... }
fn is_negative(&self) -> bool { ... }
}Expand description
This trait marks the number is signed.
Notice that the negative zeros (of f32 and f64) are still considered to have a positive sign.
§Examples
assert_eq!((-2).sign(), Sign::Negative);
assert_eq!((-2.4).sign(), Sign::Negative);
assert_eq!((0.).sign(), Sign::Positive);
assert!(2.is_positive());
assert!((-2.4).is_negative());
assert!((0.).is_positive());