Trait kurbo::common::FloatExt

source ·
pub trait FloatExt<T> {
    // Required method
    fn expand(&self) -> T;
}
Expand description

Adds convenience methods to f32 and f64.

Required Methods§

source

fn expand(&self) -> T

Rounds to the nearest integer away from zero, unless the provided value is already an integer.

It is to ceil what trunc is to floor.

§Examples
use kurbo::common::FloatExt;

let f = 3.7_f64;
let g = 3.0_f64;
let h = -3.7_f64;
let i = -5.1_f32;

assert_eq!(f.expand(), 4.0);
assert_eq!(g.expand(), 3.0);
assert_eq!(h.expand(), -4.0);
assert_eq!(i.expand(), -6.0);

Implementations on Foreign Types§

source§

impl FloatExt<f32> for f32

source§

fn expand(&self) -> f32

source§

impl FloatExt<f64> for f64

source§

fn expand(&self) -> f64

Implementors§