RoundFrom

Trait RoundFrom 

Source
pub trait RoundFrom<T> {
    // Required method
    fn round_from(x: T) -> Self;
}
Expand description

A trait for types that can be converted with precision loss.

This is our own implementation of a “lossy From” trait. It is essentially adapted from https://github.com/rust-lang/rfcs/pull/2484.

If and when such a trait is standardized, we should switch to that. Alternatively, a case can be made it should move somewhere else, or we should adopt a similar trait (it has some similarity to AsPrimitive from num_traits).

Required Methods§

Source

fn round_from(x: T) -> Self

Performs the conversion.

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 RoundFrom<f32> for f64

Source§

impl RoundFrom<f64> for f32

Source§

impl RoundFrom<Vec2> for (f32, f32)

Source§

impl RoundFrom<Vec2> for (f64, f64)

Implementors§

Source§

impl RoundFrom<(f32, f32)> for Vec2

Source§

impl RoundFrom<(f64, f64)> for Vec2

Source§

impl<T> RoundFrom<T> for T

Blanket implementation, no conversion needed.