diff --git a/src/lib.rs b/src/lib.rs index 5f8715c1..9436c358 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -82,7 +82,6 @@ Feel free to add your project to this list if you happen to use **nalgebra**! #![deny(unused_qualifications)] #![deny(unused_results)] #![warn(missing_docs)] -#![feature(core)] #![cfg_attr(test, feature(test))] #![doc(html_root_url = "http://nalgebra.org/doc")] diff --git a/src/structs/ortho.rs b/src/structs/ortho.rs index 19b38e84..39a15181 100644 --- a/src/structs/ortho.rs +++ b/src/structs/ortho.rs @@ -1,5 +1,4 @@ -use std::num; -use traits::structure::BaseFloat; +use traits::structure::{BaseFloat, Cast}; use structs::{Pnt3, Vec3, Mat4}; #[cfg(feature="arbitrary")] @@ -162,13 +161,13 @@ impl OrthoMat3 { /// The width of the view cuboid. #[inline] pub fn width(&self) -> N { - num::cast::(2.0).unwrap() / self.mat.m11 + >::from(2.0) / self.mat.m11 } /// The height of the view cuboid. #[inline] pub fn height(&self) -> N { - num::cast::(2.0).unwrap() / self.mat.m22 + >::from(2.0) / self.mat.m22 } /// The near plane offset of the view cuboid. @@ -187,14 +186,14 @@ impl OrthoMat3 { #[inline] pub fn set_width(&mut self, width: N) { assert!(!::is_zero(&width)); - self.mat.m11 = num::cast::(2.0).unwrap() / width; + self.mat.m11 = >::from(2.0) / width; } /// Sets the height of the view cuboid. #[inline] pub fn set_height(&mut self, height: N) { assert!(!::is_zero(&height)); - self.mat.m22 = num::cast::(2.0).unwrap() / height; + self.mat.m22 = >::from(2.0) / height; } /// Sets the near plane offset of the view cuboid. @@ -215,7 +214,7 @@ impl OrthoMat3 { #[inline] pub fn set_znear_and_zfar(&mut self, znear: N, zfar: N) { assert!(!::is_zero(&(zfar - znear))); - self.mat.m33 = -num::cast::(2.0).unwrap() / (zfar - znear); + self.mat.m33 = ->::from(2.0) / (zfar - znear); self.mat.m34 = -(zfar + znear) / (zfar - znear); } diff --git a/src/structs/quat.rs b/src/structs/quat.rs index 509c42f1..c1fe1a00 100644 --- a/src/structs/quat.rs +++ b/src/structs/quat.rs @@ -3,7 +3,6 @@ #![allow(missing_docs)] // we allow missing to avoid having to document the dispatch trait. use std::mem; -use std::num; use std::slice::{Iter, IterMut}; use std::ops::{Add, Sub, Mul, Div, Neg, Index, IndexMut}; use std::iter::{FromIterator, IntoIterator}; @@ -176,7 +175,7 @@ impl UnitQuat { } else { let ang = sqang.sqrt(); - let (s, c) = (ang / num::cast(2.0f64).unwrap()).sin_cos(); + let (s, c) = (ang / Cast::from(2.0)).sin_cos(); let s_ang = s / ang; @@ -205,7 +204,7 @@ impl UnitQuat { /// The primitive rotations are applied in order: 1 roll − 2 pitch − 3 yaw. #[inline] pub fn new_with_euler_angles(roll: N, pitch: N, yaw: N) -> UnitQuat { - let _0_5: N = num::cast(0.5f64).unwrap(); + let _0_5: N = Cast::from(0.5); let (sr, cr) = (roll * _0_5).sin_cos(); let (sp, cp) = (pitch * _0_5).sin_cos(); let (sy, cy) = (yaw * _0_5).sin_cos(); @@ -223,7 +222,7 @@ impl UnitQuat { /// Builds a rotation matrix from this quaternion. pub fn to_rot(&self) -> Rot3 { - let _2: N = num::cast(2.0f64).unwrap(); + let _2: N = Cast::from(2.0); let ww = self.q.w * self.q.w; let ii = self.q.i * self.q.i; let jj = self.q.j * self.q.j; diff --git a/src/traits/structure.rs b/src/traits/structure.rs index 93b0b4dd..fde314c1 100644 --- a/src/traits/structure.rs +++ b/src/traits/structure.rs @@ -16,7 +16,7 @@ pub trait BaseNum: Copy + Zero + One + } /// Basic floating-point number numeric trait. -pub trait BaseFloat: Float + BaseNum { +pub trait BaseFloat: Float + Cast + BaseNum { /// Archimedes' constant. fn pi() -> Self; /// 2.0 * pi. @@ -387,7 +387,7 @@ macro_rules! impl_base_float( /// 2.0 * pi. fn two_pi() -> $n { - $n::consts::PI_2 + 2.0 * $n::consts::PI } /// pi / 2.0.