Skip to main content

Ratio

Type Alias Ratio 

Source
pub type Ratio = Ratio;
Expand description

A dimensionless fraction: a fill factor, a sampling probability, a percentage.

Multiplying a ByteSize by one of these yields a ByteSize, so scaling a buffer by a fraction keeps its dimension.

Aliased Type§

#[repr(transparent)]
pub struct Ratio { pub dimension: PhantomData<dyn Dimension<Kind = dyn Kind, M = Z0, I = Z0, T = Z0, Th = Z0, N = Z0, L = Z0, J = Z0>>, pub units: PhantomData<dyn Units<f64, luminous_intensity = candela, amount_of_substance = mole, length = meter, electric_current = ampere, thermodynamic_temperature = kelvin, time = second, mass = kilogram>>, pub value: f64, }

Fields§

§dimension: PhantomData<dyn Dimension<Kind = dyn Kind, M = Z0, I = Z0, T = Z0, Th = Z0, N = Z0, L = Z0, J = Z0>>

Quantity dimension. See [Dimension].

§units: PhantomData<dyn Units<f64, luminous_intensity = candela, amount_of_substance = mole, length = meter, electric_current = ampere, thermodynamic_temperature = kelvin, time = second, mass = kilogram>>

Quantity base units. See [Units].

§value: f64

Quantity value stored in the base units for the quantity.

Trait Implementations§

Source§

impl Human for Ratio

Source§

type Rendered = HumanRatio

The Display adapter this quantity renders through.
Source§

fn human(self) -> Self::Rendered

This quantity, ready to print.
Source§

impl RatioExt for Ratio

Source§

const ZERO: Self

Nothing.
Source§

const ONE: Self

The whole (1.0, or 100%).
Source§

fn as_f64(self) -> f64

The fraction as a plain number, where 1.0 is the whole.
Source§

fn percent_f64(self) -> f64

The fraction as a percentage.