Skip to main content

FromF64

Trait FromF64 

Source
pub trait FromF64 {
    // Required method
    fn from_f64(value: f64) -> Self;
}
Expand description

Construct a scalar from an f64 literal.

Lives in geometry-cs rather than geometry-coords because it is only ever needed for the degree↔radian conversion factor — the rest of the kernel either uses T::ZERO / T::ONE from CoordinateScalar or stays in the scalar type the caller picked. Keeping the bound local means strategies that never touch angle units do not pay for it.

§Examples

use geometry_cs::FromF64;
assert_eq!(f64::from_f64(1.5), 1.5);
assert_eq!(f32::from_f64(1.5), 1.5_f32);

Required Methods§

Source

fn from_f64(value: f64) -> Self

Cast an f64 constant down to Self. Truncating for f32 is fine — these are conversion-factor constants, not user data.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl FromF64 for f32

Source§

fn from_f64(value: f64) -> Self

Source§

impl FromF64 for f64

Source§

fn from_f64(value: f64) -> Self

Implementors§