Skip to main content

Sign

Enum Sign 

Source
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

Source

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), "-");
Source

pub const fn negate(self) -> Self

Performs a NOT operation on the Sign type.

§Examples
assert_eq!(Sign::Positive.negate(), Sign::Negative);
assert_eq!(Sign::Negative.negate(), Sign::Positive);

Sign::negate is used in const functions.

const fn negate(sign: Sign) -> Sign {
    !sign
}
Source

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
}
Source

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
}
Source

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
}
Source

pub const fn from_byte(ch: u8) -> Self

Returns the Sign based on an ASCII byte.

Expects ‘+’ or ‘-’. Invalid values return Sign::Positive.

§Examples
assert_eq!(Sign::from_byte(b'+'), Sign::Positive);
assert_eq!(Sign::from_byte(b'-'), Sign::Negative);

Trait Implementations§

Source§

impl BitXor for Sign

Source§

type Output = Sign

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, other: Self) -> Self

Performs the ^ operation. Read more
Source§

impl BitXorAssign for Sign

Source§

fn bitxor_assign(&mut self, other: Self)

Performs the ^= operation. Read more
Source§

impl Clone for Sign

Source§

fn clone(&self) -> Sign

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Sign

Source§

impl Debug for Sign

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Sign

Source§

fn default() -> Sign

Returns the “default value” for a type. Read more
Source§

impl Eq for Sign

Source§

impl PartialEq for Sign

Source§

fn eq(&self, other: &Sign) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

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 UnsafeUnpin for Sign

§

impl UnwindSafe for Sign

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.