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

fixed some clippy warnings #165

Merged
merged 1 commit into from Sep 5, 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

@@ -19,7 +19,7 @@
//! the generic Unit parameter.
//!
//! This unit system is not mandatory and all Typed* structures have an alias
//! with the default unit: UnknownUnit.
//! with the default unit: `UnknownUnit`.
//! for example ```Point2D<T>``` is equivalent to ```TypedPoint2D<T, UnknownUnit>```.
//! Client code typically creates a set of aliases for each type and doesn't need
//! to deal with the specifics of typed units further. For example:
@@ -29,7 +29,7 @@ define_matrix! {

/// Default 2d point type with no unit.
///
/// Point2D provides the same methods as TypedPoint2D.
/// `Point2D` provides the same methods as `TypedPoint2D`.
pub type Point2D<T> = TypedPoint2D<T, UnknownUnit>;

impl<T: Copy + Zero, U> TypedPoint2D<T, U> {
@@ -273,7 +273,7 @@ define_matrix! {

/// Default 3d point type with no unit.
///
/// Point3D provides the same methods as TypedPoint3D.
/// `Point3D` provides the same methods as `TypedPoint3D`.
pub type Point3D<T> = TypedPoint3D<T, UnknownUnit>;

impl<T: Copy + Zero, U> TypedPoint3D<T, U> {
@@ -488,7 +488,7 @@ define_matrix! {

/// Default 4d point with no unit.
///
/// Point4D provides the same methods as TypedPoint4D.
/// `Point4D` provides the same methods as `TypedPoint4D`.
pub type Point4D<T> = TypedPoint4D<T, UnknownUnit>;

impl<T: Copy + Zero, U> TypedPoint4D<T, U> {
@@ -151,8 +151,8 @@ where T: Copy + Clone + Zero + PartialOrd + PartialEq + Add<T, Output=T> + Sub<T
let lower_right_x = min(self.max_x(), other.max_x());
let lower_right_y = min(self.max_y(), other.max_y());

Some(TypedRect::new(upper_left.clone(), TypedSize2D::new(lower_right_x - upper_left.x,
lower_right_y - upper_left.y)))
Some(TypedRect::new(upper_left, TypedSize2D::new(lower_right_x - upper_left.x,
lower_right_y - upper_left.y)))
}

/// Translates the rect by a vector.
@@ -203,7 +203,7 @@ where T: Copy + Clone + Zero + PartialOrd + PartialEq + Add<T, Output=T> + Sub<T

#[inline]
pub fn bottom_left(&self) -> TypedPoint2D<T, U> {
TypedPoint2D::new(self.origin.x.clone(), self.max_y())
TypedPoint2D::new(self.origin.x, self.max_y())
}

#[inline]
@@ -222,10 +222,10 @@ where T: Copy + Clone + PartialOrd + Add<T, Output=T> + Sub<T, Output=T> + Zero
#[inline]
pub fn union(&self, other: &TypedRect<T, U>) -> TypedRect<T, U> {
if self.size == Zero::zero() {
return other.clone();
return *other;
}
if other.size == Zero::zero() {
return self.clone();
return *self;
}

let upper_left = TypedPoint2D::new(min(self.min_x(), other.min_x()),
@@ -296,15 +296,15 @@ impl<T: Copy + Mul<T, Output=T>, U1, U2> Mul<ScaleFactor<T, U1, U2>> for TypedRe
type Output = TypedRect<T, U2>;
#[inline]
fn mul(self, scale: ScaleFactor<T, U1, U2>) -> TypedRect<T, U2> {
TypedRect::new(self.origin * scale.clone(), self.size * scale.clone())
TypedRect::new(self.origin * scale, self.size * scale)
}
}

impl<T: Copy + Div<T, Output=T>, U1, U2> Div<ScaleFactor<T, U1, U2>> for TypedRect<T, U2> {
type Output = TypedRect<T, U1>;
#[inline]
fn div(self, scale: ScaleFactor<T, U1, U2>) -> TypedRect<T, U1> {
TypedRect::new(self.origin / scale.clone(), self.size / scale.clone())
TypedRect::new(self.origin / scale, self.size / scale)
}
}

@@ -28,7 +28,7 @@ define_matrix! {

/// Default 2d size type with no unit.
///
/// Size2D provides the same methods as TypedSize2D.
/// `Size2D` provides the same methods as `TypedSize2D`.
pub type Size2D<T> = TypedSize2D<T, UnknownUnit>;

impl<T: fmt::Debug, U> fmt::Debug for TypedSize2D<T, U> {
@@ -172,7 +172,7 @@ impl<T: NumCast + Copy, Unit> TypedSize2D<T, Unit> {
/// as one would expect from a simple cast, but this behavior does not always marke sense
/// geometrically. Consider using round(), ceil or floor() before casting.
pub fn cast<NewT: NumCast + Copy>(&self) -> Option<TypedSize2D<NewT, Unit>> {
match (NumCast::from(self.width.clone()), NumCast::from(self.height.clone())) {
match (NumCast::from(self.width), NumCast::from(self.height)) {
(Some(w), Some(h)) => Some(TypedSize2D::new(w, h)),
_ => None
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.