godot::prelude

Trait RealConv

pub trait RealConv {
    // Required methods
    fn as_f32(self) -> f32;
    fn as_f64(self) -> f64;
    fn from_f32(f: f32) -> Self;
    fn from_f64(f: f64) -> Self;
}
Expand description

Convenience conversion between real and f32/f64.

Clippy often complains if you do f as f64 when f is already an f64. This trait exists to make it easy to convert between the different reals and floats without a lot of allowing clippy lints for your code.

Required Methods§

fn as_f32(self) -> f32

Cast this real to an f32 using as.

fn as_f64(self) -> f64

Cast this real to an f64 using as.

fn from_f32(f: f32) -> Self

Cast an f32 to a real using as.

fn from_f64(f: f64) -> Self

Cast an f64 to a real using as.

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§

§

impl RealConv for f32

§

fn as_f32(self) -> f32

§

fn as_f64(self) -> f64

§

fn from_f32(f: f32) -> f32

§

fn from_f64(f: f64) -> f32

Implementors§