Trait NumberPresentation

Source
pub trait NumberPresentation: Clone {
    const SCALE: f64;
    const RESOLUTION: Option<f64>;
}
Expand description

Number presentation.

This trait defines how to format numbers in a text field.

The SCALE corresponds to the units that are used in the text field. The value of the text field is multiplied by SCALE to give a Rust value, and likewise a Rust value is divided by the SCALE to compute the value that is displayed in the text field. For example, if the Rust value has units of Hz but the text field displays the value in units of MHz, the SCALE is 1e6.

The RESOLUTION is used to limit the number of digits that are used in the text field when displaying the value. This is done by rounding the Rust value to the nearest multiple of RESOLUTION before displaying it on the text field. For example, if the Rust value has units of Hz but the text field has a resolution of kHz, the RESOLUTION is Some(1e3). If the RESOLUTION is None, then no rounding is done and the exact Rust value is displayed in the field.

Required Associated Constants§

Source

const SCALE: f64

Scale of the text field.

This indicates how many Rust value units a text field unit consists of.

Source

const RESOLUTION: Option<f64>

Resolution of the text field.

This indicates how many Rust value units correspond to the least significant digit of the text field.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§