File tree Expand file tree Collapse file tree 2 files changed +4
-6
lines changed Expand file tree Collapse file tree 2 files changed +4
-6
lines changed Original file line number Diff line number Diff line change @@ -18,15 +18,14 @@ use approx;
1818use std:: fmt;
1919use std:: ops:: * ;
2020
21- use num_traits:: { Float , Num , NumCast } ;
21+ use num_traits:: { Float , Num } ;
2222
2323/// Base numeric types with partial ordering
2424pub 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
Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ use approx;
2525use angle:: Rad ;
2626use 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`
3131pub 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 ( ) ) ;
You can’t perform that action at this time.
0 commit comments