Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use num-traits. #137

Merged
merged 1 commit into from Apr 20, 2016
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Use num-traits.

  • Loading branch information
Ms2ger committed Apr 20, 2016
commit 61ec74c7322ce05f8d00f396f4e8d3764b73e16f
@@ -14,7 +14,7 @@ unstable = []

[dependencies]
rustc-serialize = "0.3.2"
num = {version = "0.1.24", default-features = false}
num-traits = {version = "0.1.32", default-features = false}
log = "0.3.1"
serde = {version = ">=0.6, <0.8", optional = true}
serde_macros = {version = ">=0.6, <0.8", optional = true}
@@ -11,7 +11,7 @@
use scale_factor::ScaleFactor;
use num::Zero;

use num_lib::NumCast;
use num_traits::NumCast;
#[cfg(feature = "plugins")]
use serde::{Deserialize, Deserializer, Serialize, Serializer};
use std::cmp::Ordering;
@@ -28,7 +28,7 @@ extern crate serde;
extern crate rand;
#[cfg(feature = "unstable")]
extern crate test;
extern crate num as num_lib;
extern crate num_traits;

pub use matrix::Matrix4;
pub use matrix2d::Matrix2D;
@@ -8,22 +8,22 @@
// except according to those terms.
//! A one-dimensional length, tagged with its units.

use num_lib as num;
use num_traits;


pub trait Zero {
fn zero() -> Self;
}

impl<T: num::Zero> Zero for T {
fn zero() -> T { num::Zero::zero() }
impl<T: num_traits::Zero> Zero for T {
fn zero() -> T { num_traits::Zero::zero() }
}

pub trait One {
fn one() -> Self;
}

impl<T: num::One> One for T {
fn one() -> T { num::One::one() }
impl<T: num_traits::One> One for T {
fn one() -> T { num_traits::One::one() }
}

@@ -11,8 +11,7 @@ use length::Length;
use size::Size2D;
use num::Zero;

use num_lib::NumCast;
use num_lib::traits;
use num_traits::{Float, NumCast};
use std::fmt;
use std::ops::{Add, Neg, Mul, Sub, Div};

@@ -98,7 +97,7 @@ impl <T:Clone + Neg<Output=T>> Neg for Point2D<T> {
}
}

impl<T: traits::Float> Point2D<T> {
impl<T: Float> Point2D<T> {
pub fn min(self, other: Point2D<T>) -> Point2D<T> {
Point2D::new(self.x.min(other.x), self.y.min(other.y))
}
@@ -246,7 +245,7 @@ impl <T:Clone + Neg<Output=T>> Neg for Point3D<T> {
}
}

impl<T: traits::Float> Point3D<T> {
impl<T: Float> Point3D<T> {
pub fn min(self, other: Point3D<T>) -> Point3D<T> {
Point3D::new(self.x.min(other.x), self.y.min(other.y),
self.z.min(other.z))
@@ -326,7 +325,7 @@ impl <T:Clone + Neg<Output=T>> Neg for Point4D<T> {
}
}

impl<T: traits::Float> Point4D<T> {
impl<T: Float> Point4D<T> {
pub fn min(self, other: Point4D<T>) -> Point4D<T> {
Point4D::new(self.x.min(other.x), self.y.min(other.y),
self.z.min(other.z), self.w.min(other.w))
@@ -12,7 +12,7 @@ use num::Zero;
use point::Point2D;
use size::Size2D;

use num_lib::NumCast;
use num_traits::NumCast;
use std::cmp::PartialOrd;
use std::fmt;
use std::ops::{Add, Sub, Mul, Div};
@@ -10,7 +10,7 @@

use num::One;

use num_lib::NumCast;
use num_traits::NumCast;
#[cfg(feature = "plugins")]
use serde::{Deserialize, Deserializer, Serialize, Serializer};
use std::ops::{Add, Mul, Sub, Div};
@@ -10,7 +10,7 @@
use length::Length;
use num::Zero;

use num_lib::NumCast;
use num_traits::NumCast;
use std::fmt;
use std::ops::{Mul, Div};

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.