Enum time::Sign[][src]

#[repr(i8)]
pub enum Sign {
    Positive,
    Negative,
    Zero,
}
Expand description

Contains the sign of a value: positive, negative, or zero.

For ease of use, Sign implements Mul and Div on all signed numeric types. Signs can also be multiplied and divided by another Sign, which follows the same rules as real numbers.

Variants

Positive

A positive value.

Negative

A negative value.

Zero

A value that is exactly zero.

Implementations

impl Sign[src]

pub fn negate(self) -> Self[src]

Return the opposite of the current sign.

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

pub const fn is_positive(self) -> bool[src]

Is the sign positive?

assert!(Sign::Positive.is_positive());
assert!(!Sign::Negative.is_positive());
assert!(!Sign::Zero.is_positive());

pub const fn is_negative(self) -> bool[src]

Is the sign negative?

assert!(!Sign::Positive.is_negative());
assert!(Sign::Negative.is_negative());
assert!(!Sign::Zero.is_negative());

pub const fn is_zero(self) -> bool[src]

Is the value exactly zero?

assert!(!Sign::Positive.is_zero());
assert!(!Sign::Negative.is_zero());
assert!(Sign::Zero.is_zero());

Trait Implementations

impl Clone for Sign[src]

fn clone(&self) -> Sign[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Debug for Sign[src]

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

Formats the value using the given formatter. Read more

impl Default for Sign[src]

fn default() -> Self[src]

Sign defaults to Zero.

assert_eq!(Sign::default(), Sign::Zero);

impl Div<Sign> for Sign[src]

type Output = Self

The resulting type after applying the / operator.

fn div(self, rhs: Self) -> Self::Output[src]

Performs the / operation. Read more

impl DivAssign<Sign> for Sign[src]

fn div_assign(&mut self, rhs: Self)[src]

Performs the /= operation. Read more

impl Hash for Sign[src]

fn hash<__H: Hasher>(&self, state: &mut __H)[src]

Feeds this value into the given Hasher. Read more

fn hash_slice<H>(data: &[Self], state: &mut H) where
    H: Hasher
1.3.0[src]

Feeds a slice of this type into the given Hasher. Read more

impl Mul<Sign> for Sign[src]

type Output = Self

The resulting type after applying the * operator.

fn mul(self, rhs: Self) -> Self::Output[src]

Performs the * operation. Read more

impl Mul<f32> for Sign[src]

type Output = f32

The resulting type after applying the * operator.

fn mul(self, rhs: f32) -> Self::Output[src]

Performs the * operation. Read more

impl Mul<f64> for Sign[src]

type Output = f64

The resulting type after applying the * operator.

fn mul(self, rhs: f64) -> Self::Output[src]

Performs the * operation. Read more

impl Mul<i128> for Sign[src]

type Output = i128

The resulting type after applying the * operator.

fn mul(self, rhs: i128) -> Self::Output[src]

Performs the * operation. Read more

impl Mul<i16> for Sign[src]

type Output = i16

The resulting type after applying the * operator.

fn mul(self, rhs: i16) -> Self::Output[src]

Performs the * operation. Read more

impl Mul<i32> for Sign[src]

type Output = i32

The resulting type after applying the * operator.

fn mul(self, rhs: i32) -> Self::Output[src]

Performs the * operation. Read more

impl Mul<i64> for Sign[src]

type Output = i64

The resulting type after applying the * operator.

fn mul(self, rhs: i64) -> Self::Output[src]

Performs the * operation. Read more

impl Mul<i8> for Sign[src]

type Output = i8

The resulting type after applying the * operator.

fn mul(self, rhs: i8) -> Self::Output[src]

Performs the * operation. Read more

impl MulAssign<Sign> for Sign[src]

fn mul_assign(&mut self, rhs: Self)[src]

Performs the *= operation. Read more

impl Neg for Sign[src]

type Output = Self

The resulting type after applying the - operator.

fn neg(self) -> Self::Output[src]

Performs the unary - operation. Read more

impl Not for Sign[src]

type Output = Self

The resulting type after applying the ! operator.

fn not(self) -> Self::Output[src]

Performs the unary ! operation. Read more

impl PartialEq<Sign> for Sign[src]

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

This method tests for self and other values to be equal, and is used by ==. Read more

#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests for !=.

impl Copy for Sign[src]

impl Eq for Sign[src]

impl StructuralEq for Sign[src]

impl StructuralPartialEq for Sign[src]

Auto Trait Implementations

impl RefUnwindSafe for Sign

impl Send for Sign

impl Sync for Sign

impl Unpin for Sign

impl UnwindSafe for Sign

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

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

pub fn clone_into(&self, target: &mut T)[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

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

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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

Performs the conversion.