Skip to content

Commit

Permalink
Use F::from(x) over num_traits::cast(x)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexheretic committed May 20, 2017
1 parent c27536c commit 3d258dc
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/functions/util.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
use num_traits;
pub use num_traits::Float;

/// Casts a literal f64 to an appropriate `Float` value
#[inline]
pub fn f<F: Float>(x: f64) -> F {
num_traits::cast(x).expect("cast failed, are you using non f32,f64 types?")
F::from(x).expect("cast failed, are you using non f32,f64 types?")
}

/// Macro for defining constants of generic Float type, reduces boiler plate when `f(1.23)` usage
Expand Down

0 comments on commit 3d258dc

Please sign in to comment.