pub trait IntegerToFixed: Sized + FixedForInteger {
// Required methods
fn to_fixed(&self) -> <Self as FixedForInteger>::FixedPoint;
fn from_fixed(f: &<Self as FixedForInteger>::FixedPoint) -> Self;
}Expand description
Trait for converting a numeric type to and from its associated fixed-point type.
This is intended for integer types that implement FixedForInteger,
allowing deterministic fixed-point arithmetic while preserving the original type.
Required Methods§
Sourcefn to_fixed(&self) -> <Self as FixedForInteger>::FixedPoint
fn to_fixed(&self) -> <Self as FixedForInteger>::FixedPoint
Convert the current value to the mapped fixed-point type.
Sourcefn from_fixed(f: &<Self as FixedForInteger>::FixedPoint) -> Self
fn from_fixed(f: &<Self as FixedForInteger>::FixedPoint) -> Self
Convert a value in the mapped fixed-point type back to the original type.
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 IntegerToFixed for i8
impl IntegerToFixed for i8
Source§fn to_fixed(&self) -> <i8 as FixedForInteger>::FixedPoint
fn to_fixed(&self) -> <i8 as FixedForInteger>::FixedPoint
Convert signed integer to fixed-point
Source§fn from_fixed(f: &<i8 as FixedForInteger>::FixedPoint) -> Self
fn from_fixed(f: &<i8 as FixedForInteger>::FixedPoint) -> Self
Convert fixed-point back to signed integer
Source§impl IntegerToFixed for i16
impl IntegerToFixed for i16
Source§fn to_fixed(&self) -> <i16 as FixedForInteger>::FixedPoint
fn to_fixed(&self) -> <i16 as FixedForInteger>::FixedPoint
Convert signed integer to fixed-point
Source§fn from_fixed(f: &<i16 as FixedForInteger>::FixedPoint) -> Self
fn from_fixed(f: &<i16 as FixedForInteger>::FixedPoint) -> Self
Convert fixed-point back to signed integer
Source§impl IntegerToFixed for i32
impl IntegerToFixed for i32
Source§fn to_fixed(&self) -> <i32 as FixedForInteger>::FixedPoint
fn to_fixed(&self) -> <i32 as FixedForInteger>::FixedPoint
Convert signed integer to fixed-point
Source§fn from_fixed(f: &<i32 as FixedForInteger>::FixedPoint) -> Self
fn from_fixed(f: &<i32 as FixedForInteger>::FixedPoint) -> Self
Convert fixed-point back to signed integer
Source§impl IntegerToFixed for i64
impl IntegerToFixed for i64
Source§fn to_fixed(&self) -> <i64 as FixedForInteger>::FixedPoint
fn to_fixed(&self) -> <i64 as FixedForInteger>::FixedPoint
Convert signed integer to fixed-point
Source§fn from_fixed(f: &<i64 as FixedForInteger>::FixedPoint) -> Self
fn from_fixed(f: &<i64 as FixedForInteger>::FixedPoint) -> Self
Convert fixed-point back to signed integer
Source§impl IntegerToFixed for i128
impl IntegerToFixed for i128
Source§fn to_fixed(&self) -> <i128 as FixedForInteger>::FixedPoint
fn to_fixed(&self) -> <i128 as FixedForInteger>::FixedPoint
Convert signed integer to fixed-point
Source§fn from_fixed(f: &<i128 as FixedForInteger>::FixedPoint) -> Self
fn from_fixed(f: &<i128 as FixedForInteger>::FixedPoint) -> Self
Convert fixed-point back to signed integer
Source§impl IntegerToFixed for isize
impl IntegerToFixed for isize
Source§fn to_fixed(&self) -> <isize as FixedForInteger>::FixedPoint
fn to_fixed(&self) -> <isize as FixedForInteger>::FixedPoint
Convert signed integer to fixed-point
Source§fn from_fixed(f: &<isize as FixedForInteger>::FixedPoint) -> Self
fn from_fixed(f: &<isize as FixedForInteger>::FixedPoint) -> Self
Convert fixed-point back to signed integer
Source§impl IntegerToFixed for u8
impl IntegerToFixed for u8
Source§fn to_fixed(&self) -> <u8 as FixedForInteger>::FixedPoint
fn to_fixed(&self) -> <u8 as FixedForInteger>::FixedPoint
Convert integer to fixed-point
Source§fn from_fixed(f: &<u8 as FixedForInteger>::FixedPoint) -> Self
fn from_fixed(f: &<u8 as FixedForInteger>::FixedPoint) -> Self
Convert fixed-point back to integer
Source§impl IntegerToFixed for u16
impl IntegerToFixed for u16
Source§fn to_fixed(&self) -> <u16 as FixedForInteger>::FixedPoint
fn to_fixed(&self) -> <u16 as FixedForInteger>::FixedPoint
Convert integer to fixed-point
Source§fn from_fixed(f: &<u16 as FixedForInteger>::FixedPoint) -> Self
fn from_fixed(f: &<u16 as FixedForInteger>::FixedPoint) -> Self
Convert fixed-point back to integer
Source§impl IntegerToFixed for u32
impl IntegerToFixed for u32
Source§fn to_fixed(&self) -> <u32 as FixedForInteger>::FixedPoint
fn to_fixed(&self) -> <u32 as FixedForInteger>::FixedPoint
Convert integer to fixed-point
Source§fn from_fixed(f: &<u32 as FixedForInteger>::FixedPoint) -> Self
fn from_fixed(f: &<u32 as FixedForInteger>::FixedPoint) -> Self
Convert fixed-point back to integer
Source§impl IntegerToFixed for u64
impl IntegerToFixed for u64
Source§fn to_fixed(&self) -> <u64 as FixedForInteger>::FixedPoint
fn to_fixed(&self) -> <u64 as FixedForInteger>::FixedPoint
Convert integer to fixed-point
Source§fn from_fixed(f: &<u64 as FixedForInteger>::FixedPoint) -> Self
fn from_fixed(f: &<u64 as FixedForInteger>::FixedPoint) -> Self
Convert fixed-point back to integer
Source§impl IntegerToFixed for u128
impl IntegerToFixed for u128
Source§fn to_fixed(&self) -> <u128 as FixedForInteger>::FixedPoint
fn to_fixed(&self) -> <u128 as FixedForInteger>::FixedPoint
Convert integer to fixed-point
Source§fn from_fixed(f: &<u128 as FixedForInteger>::FixedPoint) -> Self
fn from_fixed(f: &<u128 as FixedForInteger>::FixedPoint) -> Self
Convert fixed-point back to integer
Source§impl IntegerToFixed for usize
impl IntegerToFixed for usize
Source§fn to_fixed(&self) -> <usize as FixedForInteger>::FixedPoint
fn to_fixed(&self) -> <usize as FixedForInteger>::FixedPoint
Convert integer to fixed-point
Source§fn from_fixed(f: &<usize as FixedForInteger>::FixedPoint) -> Self
fn from_fixed(f: &<usize as FixedForInteger>::FixedPoint) -> Self
Convert fixed-point back to integer