Struct fugit::Rate

source ·
pub struct Rate<T, const NOM: u32, const DENOM: u32> { /* private fields */ }
Expand description

Represents a frequency.

The generic T can either be u32 or u64, and the const generics represent the ratio of the raw contained within the rate: rate in Hz = NOM / DENOM * raw

Implementations§

source§

impl<const NOM: u32, const DENOM: u32> Rate<u32, NOM, DENOM>

source

pub const fn from_raw(raw: u32) -> Self

Create a Rate from a raw value.

let _d = Rate::<u32, 1, 1_000>::from_raw(1);
source

pub const fn raw(&self) -> u32

Extract the raw value from a Rate.

let d = Rate::<u32, 1, 1_000>::from_raw(234);

assert_eq!(d.raw(), 234);
source

pub const fn checked_add<const O_NOM: u32, const O_DENOM: u32>( self, other: Rate<u32, O_NOM, O_DENOM>, ) -> Option<Self>

Add two rates while checking for overflow.

let r1 = Rate::<u32, 1, 1_000>::from_raw(1);
let r2 = Rate::<u32, 1, 1_000>::from_raw(2);
let r3 = Rate::<u32, 1, 1_000>::from_raw(u32::MAX);

assert_eq!(r1.checked_add(r2).unwrap().raw(), 3);
assert_eq!(r1.checked_add(r3), None);
source

pub const fn checked_sub<const O_NOM: u32, const O_DENOM: u32>( self, other: Rate<u32, O_NOM, O_DENOM>, ) -> Option<Self>

Subtract two rates while checking for overflow.

let r1 = Rate::<u32, 1, 1_000>::from_raw(1);
let r2 = Rate::<u32, 1, 1_000>::from_raw(2);
let r3 = Rate::<u32, 1, 1_000>::from_raw(u32::MAX);

assert_eq!(r2.checked_sub(r1).unwrap().raw(), 1);
assert_eq!(r1.checked_sub(r3), None);
source

pub const fn const_partial_cmp<const R_NOM: u32, const R_DENOM: u32>( self, other: Rate<u32, R_NOM, R_DENOM>, ) -> Option<Ordering>

Const partial comparison.

let r1 = Rate::<u32, 1, 1_00>::from_raw(1);
let r2 = Rate::<u32, 1, 1_000>::from_raw(1);

assert_eq!(r1.const_partial_cmp(r2), Some(core::cmp::Ordering::Greater));
source

pub const fn const_eq<const R_NOM: u32, const R_DENOM: u32>( self, other: Rate<u32, R_NOM, R_DENOM>, ) -> bool

Const equality check.

let r1 = Rate::<u32, 1, 1_00>::from_raw(1);
let r2 = Rate::<u32, 1, 1_000>::from_raw(10);

assert!(r1.const_eq(r2));
source

pub const fn const_try_from<const I_NOM: u32, const I_DENOM: u32>( rate: Rate<u32, I_NOM, I_DENOM>, ) -> Option<Self>

Const try from, checking for overflow.

let r1 = Rate::<u32, 1, 1_00>::from_raw(1);
let r2 = Rate::<u32, 1, 1_000>::const_try_from(r1);

assert_eq!(r2.unwrap().raw(), 10);
source

pub const fn const_try_into<const O_NOM: u32, const O_DENOM: u32>( self, ) -> Option<Rate<u32, O_NOM, O_DENOM>>

Const try into, checking for overflow.

let r1 = Rate::<u32, 1, 1_00>::from_raw(1);
let r2: Option<Rate::<u32, 1, 1_000>> = r1.const_try_into();

assert_eq!(r2.unwrap().raw(), 10);
source

pub const fn try_into_duration<const O_NOM: u32, const O_DENOM: u32>( self, ) -> Option<Duration<u32, O_NOM, O_DENOM>>

Const try into duration, checking for divide-by-zero.

let r1 = Rate::<u32, 1, 1>::from_raw(1);
let d1: Option<Duration::<u32, 1, 1_000>> = r1.try_into_duration();

assert_eq!(d1.unwrap().ticks(), 1_000);
source

pub const fn into_duration<const O_NOM: u32, const O_DENOM: u32>( self, ) -> Duration<u32, O_NOM, O_DENOM>

Convert from rate to duration.

source

pub const fn try_from_duration<const I_NOM: u32, const I_DENOM: u32>( duration: Duration<u32, I_NOM, I_DENOM>, ) -> Option<Self>

Const try from duration, checking for divide-by-zero.

let d1 = Duration::<u32, 1, 1_000>::from_ticks(2);
let r1 = Rate::<u32, 1, 1>::try_from_duration(d1);

assert_eq!(r1.unwrap().raw(), 500);
source

pub const fn from_duration<const I_NOM: u32, const I_DENOM: u32>( duration: Duration<u32, I_NOM, I_DENOM>, ) -> Self

Convert from duration to rate.

source

pub const fn convert<const O_NOM: u32, const O_DENOM: u32>( self, ) -> Rate<u32, O_NOM, O_DENOM>

Convert between bases for a rate.

Unfortunately not a From impl due to collision with the std lib.

let r1 = Rate::<u32, 1, 100>::from_raw(1);
let r2: Rate::<u32, 1, 1_000> = r1.convert();

assert_eq!(r2.raw(), 10);

Can be used in const contexts. Compilation will fail if the conversion causes overflow

const RAW: u32= u32::MAX - 10;
const R1: Rate::<u32, 1, 100> = Rate::<u32, 1, 100>::from_raw(RAW);
// Fails conversion due to overflow
const R2: Rate::<u32, 1, 200> = R1.convert();
source

pub const fn to_Hz(&self) -> u32

Convert the Rate to an interger number of Hz.

source

pub const fn to_kHz(&self) -> u32

Convert the Rate to an interger number of kHz.

source

pub const fn to_MHz(&self) -> u32

Convert the Rate to an interger number of MHz.

source

pub const fn Hz(val: u32) -> Self

Shorthand for creating a rate which represents hertz.

source

pub const fn kHz(val: u32) -> Self

Shorthand for creating a rate which represents kilohertz.

source

pub const fn MHz(val: u32) -> Self

Shorthand for creating a rate which represents megahertz.

source

pub const fn nanos(val: u32) -> Self

Shorthand for creating a rate which represents nanoseconds.

source

pub const fn micros(val: u32) -> Self

Shorthand for creating a rate which represents microseconds.

source

pub const fn millis(val: u32) -> Self

Shorthand for creating a rate which represents milliseconds.

source§

impl<const NOM: u32, const DENOM: u32> Rate<u64, NOM, DENOM>

source

pub const fn from_raw(raw: u64) -> Self

Create a Rate from a raw value.

let _d = Rate::<u64, 1, 1_000>::from_raw(1);
source

pub const fn raw(&self) -> u64

Extract the raw value from a Rate.

let d = Rate::<u64, 1, 1_000>::from_raw(234);

assert_eq!(d.raw(), 234);
source

pub const fn checked_add<const O_NOM: u32, const O_DENOM: u32>( self, other: Rate<u64, O_NOM, O_DENOM>, ) -> Option<Self>

Add two rates while checking for overflow.

let r1 = Rate::<u64, 1, 1_000>::from_raw(1);
let r2 = Rate::<u64, 1, 1_000>::from_raw(2);
let r3 = Rate::<u64, 1, 1_000>::from_raw(u64::MAX);

assert_eq!(r1.checked_add(r2).unwrap().raw(), 3);
assert_eq!(r1.checked_add(r3), None);
source

pub const fn checked_sub<const O_NOM: u32, const O_DENOM: u32>( self, other: Rate<u64, O_NOM, O_DENOM>, ) -> Option<Self>

Subtract two rates while checking for overflow.

let r1 = Rate::<u64, 1, 1_000>::from_raw(1);
let r2 = Rate::<u64, 1, 1_000>::from_raw(2);
let r3 = Rate::<u64, 1, 1_000>::from_raw(u64::MAX);

assert_eq!(r2.checked_sub(r1).unwrap().raw(), 1);
assert_eq!(r1.checked_sub(r3), None);
source

pub const fn const_partial_cmp<const R_NOM: u32, const R_DENOM: u32>( self, other: Rate<u64, R_NOM, R_DENOM>, ) -> Option<Ordering>

Const partial comparison.

let r1 = Rate::<u64, 1, 1_00>::from_raw(1);
let r2 = Rate::<u64, 1, 1_000>::from_raw(1);

assert_eq!(r1.const_partial_cmp(r2), Some(core::cmp::Ordering::Greater));
source

pub const fn const_eq<const R_NOM: u32, const R_DENOM: u32>( self, other: Rate<u64, R_NOM, R_DENOM>, ) -> bool

Const equality check.

let r1 = Rate::<u64, 1, 1_00>::from_raw(1);
let r2 = Rate::<u64, 1, 1_000>::from_raw(10);

assert!(r1.const_eq(r2));
source

pub const fn const_try_from<const I_NOM: u32, const I_DENOM: u32>( rate: Rate<u64, I_NOM, I_DENOM>, ) -> Option<Self>

Const try from, checking for overflow.

let r1 = Rate::<u64, 1, 1_00>::from_raw(1);
let r2 = Rate::<u64, 1, 1_000>::const_try_from(r1);

assert_eq!(r2.unwrap().raw(), 10);
source

pub const fn const_try_into<const O_NOM: u32, const O_DENOM: u32>( self, ) -> Option<Rate<u64, O_NOM, O_DENOM>>

Const try into, checking for overflow.

let r1 = Rate::<u64, 1, 1_00>::from_raw(1);
let r2: Option<Rate::<u64, 1, 1_000>> = r1.const_try_into();

assert_eq!(r2.unwrap().raw(), 10);
source

pub const fn try_into_duration<const O_NOM: u32, const O_DENOM: u32>( self, ) -> Option<Duration<u64, O_NOM, O_DENOM>>

Const try into duration, checking for divide-by-zero.

let r1 = Rate::<u64, 1, 1>::from_raw(1);
let d1: Option<Duration::<u64, 1, 1_000>> = r1.try_into_duration();

assert_eq!(d1.unwrap().ticks(), 1_000);
source

pub const fn into_duration<const O_NOM: u32, const O_DENOM: u32>( self, ) -> Duration<u64, O_NOM, O_DENOM>

Convert from rate to duration.

source

pub const fn try_from_duration<const I_NOM: u32, const I_DENOM: u32>( duration: Duration<u64, I_NOM, I_DENOM>, ) -> Option<Self>

Const try from duration, checking for divide-by-zero.

let d1 = Duration::<u64, 1, 1_000>::from_ticks(2);
let r1 = Rate::<u64, 1, 1>::try_from_duration(d1);

assert_eq!(r1.unwrap().raw(), 500);
source

pub const fn from_duration<const I_NOM: u32, const I_DENOM: u32>( duration: Duration<u64, I_NOM, I_DENOM>, ) -> Self

Convert from duration to rate.

source

pub const fn convert<const O_NOM: u32, const O_DENOM: u32>( self, ) -> Rate<u64, O_NOM, O_DENOM>

Convert between bases for a rate.

Unfortunately not a From impl due to collision with the std lib.

let r1 = Rate::<u64, 1, 100>::from_raw(1);
let r2: Rate::<u64, 1, 1_000> = r1.convert();

assert_eq!(r2.raw(), 10);

Can be used in const contexts. Compilation will fail if the conversion causes overflow

const RAW: u64= u64::MAX - 10;
const R1: Rate::<u64, 1, 100> = Rate::<u64, 1, 100>::from_raw(RAW);
// Fails conversion due to overflow
const R2: Rate::<u64, 1, 200> = R1.convert();
source

pub const fn to_Hz(&self) -> u64

Convert the Rate to an interger number of Hz.

source

pub const fn to_kHz(&self) -> u64

Convert the Rate to an interger number of kHz.

source

pub const fn to_MHz(&self) -> u64

Convert the Rate to an interger number of MHz.

source

pub const fn Hz(val: u64) -> Self

Shorthand for creating a rate which represents hertz.

source

pub const fn kHz(val: u64) -> Self

Shorthand for creating a rate which represents kilohertz.

source

pub const fn MHz(val: u64) -> Self

Shorthand for creating a rate which represents megahertz.

source

pub const fn nanos(val: u64) -> Self

Shorthand for creating a rate which represents nanoseconds.

source

pub const fn micros(val: u64) -> Self

Shorthand for creating a rate which represents microseconds.

source

pub const fn millis(val: u64) -> Self

Shorthand for creating a rate which represents milliseconds.

Trait Implementations§

source§

impl<const NOM: u32, const DENOM: u32> Add<Rate<u32, NOM, DENOM>> for Rate<u64, NOM, DENOM>

source§

type Output = Rate<u64, NOM, DENOM>

The resulting type after applying the + operator.
source§

fn add(self, other: Rate<u32, NOM, DENOM>) -> Self::Output

Performs the + operation. Read more
source§

impl<const NOM: u32, const DENOM: u32> Add for Rate<u32, NOM, DENOM>

source§

type Output = Rate<u32, NOM, DENOM>

The resulting type after applying the + operator.
source§

fn add(self, other: Rate<u32, NOM, DENOM>) -> Self::Output

Performs the + operation. Read more
source§

impl<const NOM: u32, const DENOM: u32> Add for Rate<u64, NOM, DENOM>

source§

type Output = Rate<u64, NOM, DENOM>

The resulting type after applying the + operator.
source§

fn add(self, other: Rate<u64, NOM, DENOM>) -> Self::Output

Performs the + operation. Read more
source§

impl<const NOM: u32, const DENOM: u32> AddAssign<Rate<u32, NOM, DENOM>> for Rate<u64, NOM, DENOM>

source§

fn add_assign(&mut self, other: Rate<u32, NOM, DENOM>)

Performs the += operation. Read more
source§

impl<const NOM: u32, const DENOM: u32> AddAssign for Rate<u32, NOM, DENOM>

source§

fn add_assign(&mut self, other: Self)

Performs the += operation. Read more
source§

impl<const NOM: u32, const DENOM: u32> AddAssign for Rate<u64, NOM, DENOM>

source§

fn add_assign(&mut self, other: Self)

Performs the += operation. Read more
source§

impl<T: Clone, const NOM: u32, const DENOM: u32> Clone for Rate<T, NOM, DENOM>

source§

fn clone(&self) -> Rate<T, NOM, DENOM>

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl<T: Debug, const NOM: u32, const DENOM: u32> Debug for Rate<T, NOM, DENOM>

source§

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

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

impl<const NOM: u32, const DENOM: u32> Display for Rate<u32, NOM, DENOM>

source§

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

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

impl<const NOM: u32, const DENOM: u32> Display for Rate<u64, NOM, DENOM>

source§

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

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

impl<const L_NOM: u32, const L_DENOM: u32, const R_NOM: u32, const R_DENOM: u32> Div<Rate<u32, R_NOM, R_DENOM>> for Rate<u32, L_NOM, L_DENOM>

source§

type Output = u32

The resulting type after applying the / operator.
source§

fn div(self, other: Rate<u32, R_NOM, R_DENOM>) -> Self::Output

Performs the / operation. Read more
source§

impl<const L_NOM: u32, const L_DENOM: u32, const R_NOM: u32, const R_DENOM: u32> Div<Rate<u64, R_NOM, R_DENOM>> for Rate<u64, L_NOM, L_DENOM>

source§

type Output = u64

The resulting type after applying the / operator.
source§

fn div(self, other: Rate<u64, R_NOM, R_DENOM>) -> Self::Output

Performs the / operation. Read more
source§

impl<const NOM: u32, const DENOM: u32> Div<u32> for Rate<u32, NOM, DENOM>

source§

type Output = Rate<u32, NOM, DENOM>

The resulting type after applying the / operator.
source§

fn div(self, other: u32) -> Self::Output

Performs the / operation. Read more
source§

impl<const NOM: u32, const DENOM: u32> Div<u32> for Rate<u64, NOM, DENOM>

source§

type Output = Rate<u64, NOM, DENOM>

The resulting type after applying the / operator.
source§

fn div(self, other: u32) -> Self::Output

Performs the / operation. Read more
source§

impl<const NOM: u32, const DENOM: u32> DivAssign<u32> for Rate<u32, NOM, DENOM>

source§

fn div_assign(&mut self, other: u32)

Performs the /= operation. Read more
source§

impl<const NOM: u32, const DENOM: u32> DivAssign<u32> for Rate<u64, NOM, DENOM>

source§

fn div_assign(&mut self, other: u32)

Performs the /= operation. Read more
source§

impl<const NOM: u32, const DENOM: u32> From<Rate<u32, NOM, DENOM>> for Rate<u64, NOM, DENOM>

source§

fn from(val: Rate<u32, NOM, DENOM>) -> Rate<u64, NOM, DENOM>

Converts to this type from the input type.
source§

impl<const NOM: u32, const DENOM: u32> Mul<Rate<u32, NOM, DENOM>> for u32

source§

type Output = Rate<u32, NOM, DENOM>

The resulting type after applying the * operator.
source§

fn mul(self, other: Rate<u32, NOM, DENOM>) -> Self::Output

Performs the * operation. Read more
source§

impl<const NOM: u32, const DENOM: u32> Mul<Rate<u64, NOM, DENOM>> for u32

source§

type Output = Rate<u64, NOM, DENOM>

The resulting type after applying the * operator.
source§

fn mul(self, other: Rate<u64, NOM, DENOM>) -> Self::Output

Performs the * operation. Read more
source§

impl<const NOM: u32, const DENOM: u32> Mul<u32> for Rate<u32, NOM, DENOM>

source§

type Output = Rate<u32, NOM, DENOM>

The resulting type after applying the * operator.
source§

fn mul(self, other: u32) -> Self::Output

Performs the * operation. Read more
source§

impl<const NOM: u32, const DENOM: u32> Mul<u32> for Rate<u64, NOM, DENOM>

source§

type Output = Rate<u64, NOM, DENOM>

The resulting type after applying the * operator.
source§

fn mul(self, other: u32) -> Self::Output

Performs the * operation. Read more
source§

impl<const NOM: u32, const DENOM: u32> MulAssign<u32> for Rate<u32, NOM, DENOM>

source§

fn mul_assign(&mut self, other: u32)

Performs the *= operation. Read more
source§

impl<const NOM: u32, const DENOM: u32> MulAssign<u32> for Rate<u64, NOM, DENOM>

source§

fn mul_assign(&mut self, other: u32)

Performs the *= operation. Read more
source§

impl<const NOM: u32, const DENOM: u32> Ord for Rate<u32, NOM, DENOM>

source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized + PartialOrd,

Restrict a value to a certain interval. Read more
source§

impl<const NOM: u32, const DENOM: u32> Ord for Rate<u64, NOM, DENOM>

source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized + PartialOrd,

Restrict a value to a certain interval. Read more
source§

impl<const L_NOM: u32, const L_DENOM: u32, const R_NOM: u32, const R_DENOM: u32> PartialEq<Rate<u32, R_NOM, R_DENOM>> for Rate<u32, L_NOM, L_DENOM>

source§

fn eq(&self, other: &Rate<u32, R_NOM, R_DENOM>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<const L_NOM: u32, const L_DENOM: u32, const R_NOM: u32, const R_DENOM: u32> PartialEq<Rate<u32, R_NOM, R_DENOM>> for Rate<u64, L_NOM, L_DENOM>

source§

fn eq(&self, other: &Rate<u32, R_NOM, R_DENOM>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<const L_NOM: u32, const L_DENOM: u32, const R_NOM: u32, const R_DENOM: u32> PartialEq<Rate<u64, R_NOM, R_DENOM>> for Rate<u32, L_NOM, L_DENOM>

source§

fn eq(&self, other: &Rate<u64, R_NOM, R_DENOM>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<const L_NOM: u32, const L_DENOM: u32, const R_NOM: u32, const R_DENOM: u32> PartialEq<Rate<u64, R_NOM, R_DENOM>> for Rate<u64, L_NOM, L_DENOM>

source§

fn eq(&self, other: &Rate<u64, R_NOM, R_DENOM>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<const L_NOM: u32, const L_DENOM: u32, const R_NOM: u32, const R_DENOM: u32> PartialOrd<Rate<u32, R_NOM, R_DENOM>> for Rate<u32, L_NOM, L_DENOM>

source§

fn partial_cmp(&self, other: &Rate<u32, R_NOM, R_DENOM>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<const L_NOM: u32, const L_DENOM: u32, const R_NOM: u32, const R_DENOM: u32> PartialOrd<Rate<u32, R_NOM, R_DENOM>> for Rate<u64, L_NOM, L_DENOM>

source§

fn partial_cmp(&self, other: &Rate<u32, R_NOM, R_DENOM>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<const L_NOM: u32, const L_DENOM: u32, const R_NOM: u32, const R_DENOM: u32> PartialOrd<Rate<u64, R_NOM, R_DENOM>> for Rate<u32, L_NOM, L_DENOM>

source§

fn partial_cmp(&self, other: &Rate<u64, R_NOM, R_DENOM>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<const L_NOM: u32, const L_DENOM: u32, const R_NOM: u32, const R_DENOM: u32> PartialOrd<Rate<u64, R_NOM, R_DENOM>> for Rate<u64, L_NOM, L_DENOM>

source§

fn partial_cmp(&self, other: &Rate<u64, R_NOM, R_DENOM>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<const NOM: u32, const DENOM: u32> Sub<Rate<u32, NOM, DENOM>> for Rate<u64, NOM, DENOM>

source§

type Output = Rate<u64, NOM, DENOM>

The resulting type after applying the - operator.
source§

fn sub(self, other: Rate<u32, NOM, DENOM>) -> Self::Output

Performs the - operation. Read more
source§

impl<const NOM: u32, const DENOM: u32> Sub for Rate<u32, NOM, DENOM>

source§

type Output = Rate<u32, NOM, DENOM>

The resulting type after applying the - operator.
source§

fn sub(self, other: Rate<u32, NOM, DENOM>) -> Self::Output

Performs the - operation. Read more
source§

impl<const NOM: u32, const DENOM: u32> Sub for Rate<u64, NOM, DENOM>

source§

type Output = Rate<u64, NOM, DENOM>

The resulting type after applying the - operator.
source§

fn sub(self, other: Rate<u64, NOM, DENOM>) -> Self::Output

Performs the - operation. Read more
source§

impl<const NOM: u32, const DENOM: u32> SubAssign<Rate<u32, NOM, DENOM>> for Rate<u64, NOM, DENOM>

source§

fn sub_assign(&mut self, other: Rate<u32, NOM, DENOM>)

Performs the -= operation. Read more
source§

impl<const NOM: u32, const DENOM: u32> TryFrom<Rate<u64, NOM, DENOM>> for Rate<u32, NOM, DENOM>

source§

type Error = ()

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

fn try_from(val: Rate<u64, NOM, DENOM>) -> Result<Rate<u32, NOM, DENOM>, ()>

Performs the conversion.
source§

impl<T: Copy, const NOM: u32, const DENOM: u32> Copy for Rate<T, NOM, DENOM>

source§

impl<const NOM: u32, const DENOM: u32> Eq for Rate<u32, NOM, DENOM>

source§

impl<const NOM: u32, const DENOM: u32> Eq for Rate<u64, NOM, DENOM>

Auto Trait Implementations§

§

impl<T, const NOM: u32, const DENOM: u32> Freeze for Rate<T, NOM, DENOM>
where T: Freeze,

§

impl<T, const NOM: u32, const DENOM: u32> RefUnwindSafe for Rate<T, NOM, DENOM>
where T: RefUnwindSafe,

§

impl<T, const NOM: u32, const DENOM: u32> Send for Rate<T, NOM, DENOM>
where T: Send,

§

impl<T, const NOM: u32, const DENOM: u32> Sync for Rate<T, NOM, DENOM>
where T: Sync,

§

impl<T, const NOM: u32, const DENOM: u32> Unpin for Rate<T, NOM, DENOM>
where T: Unpin,

§

impl<T, const NOM: u32, const DENOM: u32> UnwindSafe for Rate<T, NOM, DENOM>
where T: UnwindSafe,

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, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

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

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

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.