pub enum Sign {
Positive,
Negative,
}
Expand description
Sign of the floating-point number.
Variants§
Positive
Indicate positive floating-point numbers.
Negative
Indicate negative floating-point numbers.
Implementations§
Source§impl Sign
impl Sign
Sourcepub const fn as_str(&self, force_sign: bool) -> &'static str
pub const fn as_str(&self, force_sign: bool) -> &'static str
Returns the display of this character as a &’static str.
§Examples
assert_eq!(Sign::Positive.as_str(false), "");
assert_eq!(Sign::Positive.as_str(true), "+");
assert_eq!(Sign::Negative.as_str(false), "-");
assert_eq!(Sign::Negative.as_str(true), "-");
Sourcepub const fn xor(self, other: Self) -> Self
pub const fn xor(self, other: Self) -> Self
Performs an XOR operation on two Sign
types.
§Examples
assert_eq!(Sign::Positive.xor(Sign::Positive), Sign::Positive);
assert_eq!(Sign::Positive.xor(Sign::Negative), Sign::Negative);
assert_eq!(Sign::Negative.xor(Sign::Positive), Sign::Negative);
assert_eq!(Sign::Negative.xor(Sign::Negative), Sign::Positive);
Sign::xor
is used in const
functions.
ⓘ
const fn xor(sign1: Sign, sign2: Sign) -> Sign {
sign1 ^ sign2
}
Sourcepub const fn is_positive(&self) -> bool
pub const fn is_positive(&self) -> bool
Returns true of the Sign
is Positive
.
§Examples
let positive = Sign::Positive;
let negative = Sign::Negative;
assert_eq!(Sign::Positive.is_positive(), true);
assert_eq!(negative.is_positive(), false);
Sign::is_positive
is used in const
functions.
ⓘ
const fn is_positive(sign: Sign) -> bool {
Sign::Positive == sign
}
Sourcepub const fn is_negative(&self) -> bool
pub const fn is_negative(&self) -> bool
Returns true of the Sign
is Negative
.
§Examples
let positive = Sign::Positive;
let negative = Sign::Negative;
assert_eq!(Sign::Positive.is_negative(), false);
assert_eq!(negative.is_negative(), true);
Sign::is_negative
is used in const
functions.
ⓘ
const fn is_negative(sign: Sign) -> bool {
Sign::Negative == sign
}
Trait Implementations§
Source§impl BitXorAssign for Sign
impl BitXorAssign for Sign
Source§fn bitxor_assign(&mut self, other: Self)
fn bitxor_assign(&mut self, other: Self)
Performs the
^=
operation. Read moreimpl 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