Skip to content

Commit 41fb64c

Browse files
spearmankvark
authored andcommitted
Remove NumCast bound from BaseNum
1 parent e57b543 commit 41fb64c

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

src/num.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,14 @@ use approx;
1818
use std::fmt;
1919
use std::ops::*;
2020

21-
use num_traits::{Float, Num, NumCast};
21+
use num_traits::{Float, Num};
2222

2323
/// Base numeric types with partial ordering
2424
pub trait BaseNum:
2525
Copy
2626
+ Clone
2727
+ fmt::Debug
2828
+ Num
29-
+ NumCast
3029
+ PartialOrd
3130
+ AddAssign
3231
+ SubAssign
@@ -41,7 +40,6 @@ impl<T> BaseNum for T where
4140
+ Clone
4241
+ fmt::Debug
4342
+ Num
44-
+ NumCast
4543
+ PartialOrd
4644
+ AddAssign
4745
+ SubAssign

src/structure.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use approx;
2525
use angle::Rad;
2626
use num::{BaseFloat, BaseNum};
2727

28-
pub use num_traits::{Bounded, One, Zero};
28+
pub use num_traits::{Bounded, NumCast, One, Zero};
2929

3030
/// An array containing elements of type `Element`
3131
pub trait Array
@@ -388,7 +388,7 @@ where
388388
/// ```
389389
#[inline]
390390
fn midpoint(self, other: Self) -> Self {
391-
self + (other - self) / cast(2).unwrap()
391+
self + (other - self) / (Self::Scalar::one() + Self::Scalar::one())
392392
}
393393

394394
/// Returns the average position of all points in the slice.
@@ -406,7 +406,7 @@ where
406406
/// let centroid = Point2::centroid(&triangle);
407407
/// ```
408408
#[inline]
409-
fn centroid(points: &[Self]) -> Self {
409+
fn centroid(points: &[Self]) -> Self where Self::Scalar: NumCast {
410410
let total_displacement = points
411411
.iter()
412412
.fold(Self::Diff::zero(), |acc, p| acc + p.to_vec());

0 commit comments

Comments
 (0)