SpinValue

Trait SpinValue 

Source
pub trait SpinValue:
    Copy
    + PartialOrd
    + Debug
    + FromStr
    + ToString
    + Cast<f64>
    + ConvApprox<f64>
    + 'static {
    // Required methods
    fn default_step() -> Self;
    fn add_step(self, step: Self) -> Self;
    fn sub_step(self, step: Self) -> Self;

    // Provided method
    fn clamp(self, l_bound: Self, u_bound: Self) -> Self { ... }
}
Expand description

Requirements on type used by SpinBox

Implementations are provided for standard float and integer types.

The type must support conversion to and approximate conversion from f64 in order to enable programmatic control (e.g. tests, accessibility tools). NOTE: this restriction might be revised in the future once Rust supports specialization.

Required Methods§

Source

fn default_step() -> Self

The default step size (usually 1)

Source

fn add_step(self, step: Self) -> Self

Add step without wrapping

The implementation should saturate on overflow, at least for fixed-precision types.

Source

fn sub_step(self, step: Self) -> Self

Subtract step without wrapping

The implementation should saturate on overflow, at least for fixed-precision types.

Provided Methods§

Source

fn clamp(self, l_bound: Self, u_bound: Self) -> Self

Clamp self to the range l_bound..=u_bound

The default implementation is equivalent to the std implementations for Ord and for floating-point types.

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.

Implementations on Foreign Types§

Source§

impl SpinValue for f32

Source§

fn default_step() -> Self

Source§

fn add_step(self, step: Self) -> Self

Source§

fn sub_step(self, step: Self) -> Self

Source§

fn clamp(self, l_bound: Self, u_bound: Self) -> Self

Source§

impl SpinValue for f64

Source§

fn default_step() -> Self

Source§

fn add_step(self, step: Self) -> Self

Source§

fn sub_step(self, step: Self) -> Self

Source§

fn clamp(self, l_bound: Self, u_bound: Self) -> Self

Source§

impl SpinValue for i8

Source§

fn default_step() -> Self

Source§

fn add_step(self, step: Self) -> Self

Source§

fn sub_step(self, step: Self) -> Self

Source§

fn clamp(self, l_bound: Self, u_bound: Self) -> Self

Source§

impl SpinValue for i16

Source§

fn default_step() -> Self

Source§

fn add_step(self, step: Self) -> Self

Source§

fn sub_step(self, step: Self) -> Self

Source§

fn clamp(self, l_bound: Self, u_bound: Self) -> Self

Source§

impl SpinValue for i32

Source§

fn default_step() -> Self

Source§

fn add_step(self, step: Self) -> Self

Source§

fn sub_step(self, step: Self) -> Self

Source§

fn clamp(self, l_bound: Self, u_bound: Self) -> Self

Source§

impl SpinValue for i64

Source§

fn default_step() -> Self

Source§

fn add_step(self, step: Self) -> Self

Source§

fn sub_step(self, step: Self) -> Self

Source§

fn clamp(self, l_bound: Self, u_bound: Self) -> Self

Source§

impl SpinValue for i128

Source§

fn default_step() -> Self

Source§

fn add_step(self, step: Self) -> Self

Source§

fn sub_step(self, step: Self) -> Self

Source§

fn clamp(self, l_bound: Self, u_bound: Self) -> Self

Source§

impl SpinValue for isize

Source§

fn default_step() -> Self

Source§

fn add_step(self, step: Self) -> Self

Source§

fn sub_step(self, step: Self) -> Self

Source§

fn clamp(self, l_bound: Self, u_bound: Self) -> Self

Source§

impl SpinValue for u8

Source§

fn default_step() -> Self

Source§

fn add_step(self, step: Self) -> Self

Source§

fn sub_step(self, step: Self) -> Self

Source§

fn clamp(self, l_bound: Self, u_bound: Self) -> Self

Source§

impl SpinValue for u16

Source§

fn default_step() -> Self

Source§

fn add_step(self, step: Self) -> Self

Source§

fn sub_step(self, step: Self) -> Self

Source§

fn clamp(self, l_bound: Self, u_bound: Self) -> Self

Source§

impl SpinValue for u32

Source§

fn default_step() -> Self

Source§

fn add_step(self, step: Self) -> Self

Source§

fn sub_step(self, step: Self) -> Self

Source§

fn clamp(self, l_bound: Self, u_bound: Self) -> Self

Source§

impl SpinValue for u64

Source§

fn default_step() -> Self

Source§

fn add_step(self, step: Self) -> Self

Source§

fn sub_step(self, step: Self) -> Self

Source§

fn clamp(self, l_bound: Self, u_bound: Self) -> Self

Source§

impl SpinValue for u128

Source§

fn default_step() -> Self

Source§

fn add_step(self, step: Self) -> Self

Source§

fn sub_step(self, step: Self) -> Self

Source§

fn clamp(self, l_bound: Self, u_bound: Self) -> Self

Source§

impl SpinValue for usize

Source§

fn default_step() -> Self

Source§

fn add_step(self, step: Self) -> Self

Source§

fn sub_step(self, step: Self) -> Self

Source§

fn clamp(self, l_bound: Self, u_bound: Self) -> Self

Implementors§