Skip to content

Commit df21854

Browse files
Rémi Lauzierkvark
authored andcommitted
Fix some clippy warnings and some typo
1 parent 575c458 commit df21854

File tree

14 files changed

+46
-50
lines changed

14 files changed

+46
-50
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
5151
- Add `Array::len`
5252
- Re-export `Bounded` and implement for vectors, points, and angles
5353
- Add vector subtraction to `EuclideanSpace`
54-
- Add swizzle functions behinde that `"swizzle"` feature
54+
- Add swizzle functions behind that `"swizzle"` feature
5555
- Add `Matrix4::look_at_dir`
5656

5757
### Changed

build.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use std::string::String;
77
/// Generate the name of the swizzle function and what it returns.
88
/// NOTE: This function assumes that variables are in ASCII format
99
#[cfg(feature = "swizzle")]
10-
fn gen_swizzle_nth<'a>(variables: &'a str, mut i: usize, upto: usize) -> Option<(String, String)> {
10+
fn gen_swizzle_nth(variables: &str, mut i: usize, upto: usize) -> Option<(String, String)> {
1111
debug_assert!(i > 0); // zeroth permutation is empty
1212
let mut swizzle_impl = String::new();
1313
let mut swizzle = String::new();
@@ -22,7 +22,7 @@ fn gen_swizzle_nth<'a>(variables: &'a str, mut i: usize, upto: usize) -> Option<
2222
let c = variables.as_bytes()[i % n - 1] as char;
2323
swizzle.push(c);
2424
swizzle_impl.push_str(&format!("self.{}, ", c));
25-
i = i / n;
25+
i /= n;
2626
}
2727
Some((swizzle, swizzle_impl))
2828
}

src/conv.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
//! let uniforms = uniform! {
2121
//! point: Into::<[_; 2]>::into(point),
2222
//! matrix: Into::<[[_; 4]; 4]>::into(matrix),
23-
//! // Yuck!! (ノಥ益ಥ)ノ ┻━┻
23+
//! // Yuck!! (ノಥ益ಥ)ノ ┻━┻)
2424
//! };
2525
//! # }
2626
//! ` ` `

src/macros.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ macro_rules! impl_tuple_conversions {
218218
impl<$S> From<$Tuple> for $ArrayN<$S> {
219219
#[inline]
220220
fn from(v: $Tuple) -> $ArrayN<$S> {
221-
match v { ($($field),+,) => $ArrayN { $($field: $field),+ } }
221+
match v { ($($field),+,) => $ArrayN { $($field),+ } }
222222
}
223223
}
224224

src/matrix.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -563,8 +563,8 @@ impl<S: BaseFloat> VectorSpace for Matrix4<S> {
563563
}
564564

565565
impl<S: BaseFloat> Matrix for Matrix2<S> {
566-
type Column = Vector2<S>;
567566
type Row = Vector2<S>;
567+
type Column = Vector2<S>;
568568
type Transpose = Matrix2<S>;
569569

570570
#[inline]
@@ -661,8 +661,8 @@ impl<S: BaseFloat> SquareMatrix for Matrix2<S> {
661661
}
662662

663663
impl<S: BaseFloat> Matrix for Matrix3<S> {
664-
type Column = Vector3<S>;
665664
type Row = Vector3<S>;
665+
type Column = Vector3<S>;
666666
type Transpose = Matrix3<S>;
667667

668668
#[inline]
@@ -776,8 +776,8 @@ impl<S: BaseFloat> SquareMatrix for Matrix3<S> {
776776
}
777777

778778
impl<S: BaseFloat> Matrix for Matrix4<S> {
779-
type Column = Vector4<S>;
780779
type Row = Vector4<S>;
780+
type Column = Vector4<S>;
781781
type Transpose = Matrix4<S>;
782782

783783
#[inline]
@@ -1092,13 +1092,13 @@ impl<S: BaseFloat> Transform<Point2<S>> for Matrix3<S> {
10921092
Matrix3::from(Matrix2::look_at(dir, up))
10931093
}
10941094

1095-
fn look_at_lh(eye: Point2<S>, center: Point2<S>, up: Vector2<S>) -> Matrix3<S> {
1096-
let dir = center - eye;
1095+
fn look_at_rh(eye: Point2<S>, center: Point2<S>, up: Vector2<S>) -> Matrix3<S> {
1096+
let dir = eye - center;
10971097
Matrix3::from(Matrix2::look_at(dir, up))
10981098
}
10991099

1100-
fn look_at_rh(eye: Point2<S>, center: Point2<S>, up: Vector2<S>) -> Matrix3<S> {
1101-
let dir = eye - center;
1100+
fn look_at_lh(eye: Point2<S>, center: Point2<S>, up: Vector2<S>) -> Matrix3<S> {
1101+
let dir = center - eye;
11021102
Matrix3::from(Matrix2::look_at(dir, up))
11031103
}
11041104

@@ -1125,14 +1125,14 @@ impl<S: BaseFloat> Transform<Point3<S>> for Matrix3<S> {
11251125
Matrix3::look_to_lh(dir, up)
11261126
}
11271127

1128-
fn look_at_lh(eye: Point3<S>, center: Point3<S>, up: Vector3<S>) -> Matrix3<S> {
1128+
fn look_at_rh(eye: Point3<S>, center: Point3<S>, up: Vector3<S>) -> Matrix3<S> {
11291129
let dir = center - eye;
1130-
Matrix3::look_to_lh(dir, up)
1130+
Matrix3::look_to_rh(dir, up)
11311131
}
11321132

1133-
fn look_at_rh(eye: Point3<S>, center: Point3<S>, up: Vector3<S>) -> Matrix3<S> {
1133+
fn look_at_lh(eye: Point3<S>, center: Point3<S>, up: Vector3<S>) -> Matrix3<S> {
11341134
let dir = center - eye;
1135-
Matrix3::look_to_rh(dir, up)
1135+
Matrix3::look_to_lh(dir, up)
11361136
}
11371137

11381138
fn transform_vector(&self, vec: Vector3<S>) -> Vector3<S> {
@@ -1157,14 +1157,14 @@ impl<S: BaseFloat> Transform<Point3<S>> for Matrix4<S> {
11571157
Matrix4::look_at_rh(eye, center, up)
11581158
}
11591159

1160-
fn look_at_lh(eye: Point3<S>, center: Point3<S>, up: Vector3<S>) -> Matrix4<S> {
1161-
Matrix4::look_at_lh(eye, center, up)
1162-
}
1163-
11641160
fn look_at_rh(eye: Point3<S>, center: Point3<S>, up: Vector3<S>) -> Matrix4<S> {
11651161
Matrix4::look_at_rh(eye, center, up)
11661162
}
11671163

1164+
fn look_at_lh(eye: Point3<S>, center: Point3<S>, up: Vector3<S>) -> Matrix4<S> {
1165+
Matrix4::look_at_lh(eye, center, up)
1166+
}
1167+
11681168
fn transform_vector(&self, vec: Vector3<S>) -> Vector3<S> {
11691169
(self * vec.extend(S::zero())).truncate()
11701170
}

src/point.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ macro_rules! impl_point {
8383
/// Construct a new point, using the provided values.
8484
#[inline]
8585
pub const fn new($($field: S),+) -> $PointN<S> {
86-
$PointN { $($field: $field),+ }
86+
$PointN { $($field),+ }
8787
}
8888

8989
/// Perform the given operation on each field in the point, returning a new point
@@ -405,7 +405,7 @@ mod tests {
405405
#[test]
406406
fn test_index_mut() {
407407
let mut p = POINT2;
408-
*&mut p[0] = 0;
408+
p[0] = 0;
409409
assert_eq!(p, [0, 2].into());
410410
}
411411

@@ -518,7 +518,7 @@ mod tests {
518518
#[test]
519519
fn test_index_mut() {
520520
let mut p = POINT3;
521-
*&mut p[1] = 0;
521+
p[1] = 0;
522522
assert_eq!(p, [1, 0, 3].into());
523523
}
524524

src/quaternion_simd.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ impl From<Simdf32x4> for Quaternion<f32> {
2626
#[inline]
2727
fn from(f: Simdf32x4) -> Self {
2828
unsafe {
29-
let mut ret: Self = mem::uninitialized();
29+
let mut ret: Self = mem::MaybeUninit();
3030
{
3131
let ret_mut: &mut [f32; 4] = ret.as_mut();
3232
f.store(ret_mut.as_mut(), 0 as usize);

src/rotation.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ pub trait Rotation3:
149149
/// let unit_y = rot.rotate_vector(unit_x);
150150
///
151151
/// // Since sin(π/2) may not be exactly zero due to rounding errors, we can
152-
/// // use approx's assert_ulps_eq!() feature to show that it is close enough.
152+
/// // use approx assert_ulps_eq!() feature to show that it is close enough.
153153
/// // assert_ulps_eq!(&unit_y, &Vector2::unit_y()); // TODO: Figure out how to use this
154154
///
155155
/// // This is exactly equivalent to using the raw matrix itself:
@@ -319,7 +319,7 @@ impl<S: BaseFloat> Basis3<S> {
319319
#[inline]
320320
pub fn from_quaternion(quaternion: &Quaternion<S>) -> Basis3<S> {
321321
Basis3 {
322-
mat: quaternion.clone().into(),
322+
mat: (*quaternion).into(),
323323
}
324324
}
325325
}

src/structure.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -580,10 +580,10 @@ where
580580
fn is_symmetric(&self) -> bool;
581581
}
582582

583-
/// Angles and their associated trigonometric functions.
583+
/// Angles, and their associated trigonometric functions.
584584
///
585585
/// Typed angles allow for the writing of self-documenting code that makes it
586-
/// clear when semantic violations have occured - for example, adding degrees to
586+
/// clear when semantic violations have occurred - for example, adding degrees to
587587
/// radians, or adding a number to an angle.
588588
///
589589
pub trait Angle
@@ -609,7 +609,7 @@ where
609609
{
610610
type Unitless: BaseFloat;
611611

612-
/// Return the angle, normalized to the range `[0, full_turn)`.
612+
/// Return the angle, normalized to the range `[0, full_turn]`.
613613
#[inline]
614614
fn normalize(self) -> Self {
615615
let rem = self % Self::full_turn();
@@ -620,7 +620,7 @@ where
620620
}
621621
}
622622

623-
/// Return the angle, normalized to the range `[-turn_div_2, turn_div_2)`.
623+
/// Return the angle, normalized to the range `[-turn_div_2, turn_div_2]`.
624624
#[inline]
625625
fn normalize_signed(self) -> Self {
626626
let rem = self.normalize();

src/transform.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ where
123123
}
124124

125125
#[inline]
126-
fn look_at_lh(eye: P, center: P, up: P::Diff) -> Decomposed<P::Diff, R> {
127-
let rot = R::look_at(center - eye, up);
126+
fn look_at_rh(eye: P, center: P, up: P::Diff) -> Decomposed<P::Diff, R> {
127+
let rot = R::look_at(eye - center, up);
128128
let disp = rot.rotate_vector(P::origin() - eye);
129129
Decomposed {
130130
scale: P::Scalar::one(),
@@ -134,8 +134,8 @@ where
134134
}
135135

136136
#[inline]
137-
fn look_at_rh(eye: P, center: P, up: P::Diff) -> Decomposed<P::Diff, R> {
138-
let rot = R::look_at(eye - center, up);
137+
fn look_at_lh(eye: P, center: P, up: P::Diff) -> Decomposed<P::Diff, R> {
138+
let rot = R::look_at(center - eye, up);
139139
let disp = rot.rotate_vector(P::origin() - eye);
140140
Decomposed {
141141
scale: P::Scalar::one(),
@@ -366,7 +366,7 @@ mod serde_de {
366366
where
367367
D: serde::de::Deserializer<'a>,
368368
{
369-
const FIELDS: &'static [&'static str] = &["scale", "rot", "disp"];
369+
const FIELDS: &[&str] = &["scale", "rot", "disp"];
370370
deserializer.deserialize_struct("Decomposed", FIELDS, DecomposedVisitor(PhantomData))
371371
}
372372
}
@@ -422,11 +422,7 @@ mod serde_de {
422422
None => return Err(serde::de::Error::missing_field("disp")),
423423
};
424424

425-
Ok(Decomposed {
426-
scale: scale,
427-
rot: rot,
428-
disp: disp,
429-
})
425+
Ok(Decomposed { scale, rot, disp })
430426
}
431427
}
432428
}

0 commit comments

Comments
 (0)