diff --git a/nalgebra-lapack/src/cholesky.rs b/nalgebra-lapack/src/cholesky.rs index 3976373d..02552915 100644 --- a/nalgebra-lapack/src/cholesky.rs +++ b/nalgebra-lapack/src/cholesky.rs @@ -62,7 +62,7 @@ where DefaultAllocator: Allocator N::xpotrf(uplo, dim, m.as_mut_slice(), dim, &mut info); lapack_check!(info); - Some(Cholesky { l: m }) + Some(Self { l: m }) } /// Retrieves the lower-triangular factor of the cholesky decomposition. diff --git a/nalgebra-lapack/src/eigen.rs b/nalgebra-lapack/src/eigen.rs index d95219cb..fbc49319 100644 --- a/nalgebra-lapack/src/eigen.rs +++ b/nalgebra-lapack/src/eigen.rs @@ -127,7 +127,7 @@ where DefaultAllocator: Allocator + Allocator lapack_check!(info); if wi.iter().all(|e| e.is_zero()) { - return Some(Eigen { + return Some(Self { eigenvalues: wr, left_eigenvectors: Some(vl), eigenvectors: Some(vr), @@ -156,7 +156,7 @@ where DefaultAllocator: Allocator + Allocator lapack_check!(info); if wi.iter().all(|e| e.is_zero()) { - return Some(Eigen { + return Some(Self { eigenvalues: wr, left_eigenvectors: Some(vl), eigenvectors: None, @@ -185,7 +185,7 @@ where DefaultAllocator: Allocator + Allocator lapack_check!(info); if wi.iter().all(|e| e.is_zero()) { - return Some(Eigen { + return Some(Self { eigenvalues: wr, left_eigenvectors: None, eigenvectors: Some(vr), @@ -212,7 +212,7 @@ where DefaultAllocator: Allocator + Allocator lapack_check!(info); if wi.iter().all(|e| e.is_zero()) { - return Some(Eigen { + return Some(Self { eigenvalues: wr, left_eigenvectors: None, eigenvectors: None, diff --git a/nalgebra-lapack/src/hessenberg.rs b/nalgebra-lapack/src/hessenberg.rs index 6bfa673b..65a27d1e 100644 --- a/nalgebra-lapack/src/hessenberg.rs +++ b/nalgebra-lapack/src/hessenberg.rs @@ -48,7 +48,7 @@ impl> Hessenberg where DefaultAllocator: Allocator + Allocator> { /// Computes the hessenberg decomposition of the matrix `m`. - pub fn new(mut m: MatrixN) -> Hessenberg { + pub fn new(mut m: MatrixN) -> Self { let nrows = m.data.shape().0; let n = nrows.value() as i32; @@ -83,7 +83,7 @@ where DefaultAllocator: Allocator + Allocator> ); lapack_panic!(info); - Hessenberg { h: m, tau: tau } + Self { h: m, tau: tau } } /// Computes the hessenberg matrix of this decomposition. diff --git a/nalgebra-lapack/src/lu.rs b/nalgebra-lapack/src/lu.rs index c9b1167c..ad76e245 100644 --- a/nalgebra-lapack/src/lu.rs +++ b/nalgebra-lapack/src/lu.rs @@ -82,7 +82,7 @@ where ); lapack_panic!(info); - LU { lu: m, p: ipiv } + Self { lu: m, p: ipiv } } /// Gets the lower-triangular matrix part of the decomposition. diff --git a/nalgebra-lapack/src/qr.rs b/nalgebra-lapack/src/qr.rs index 66220e49..1fa9b066 100644 --- a/nalgebra-lapack/src/qr.rs +++ b/nalgebra-lapack/src/qr.rs @@ -54,14 +54,14 @@ where DefaultAllocator: Allocator + Allocator> { /// Computes the QR decomposition of the matrix `m`. - pub fn new(mut m: MatrixMN) -> QR { + pub fn new(mut m: MatrixMN) -> Self { let (nrows, ncols) = m.data.shape(); let mut info = 0; let mut tau = unsafe { Matrix::new_uninitialized_generic(nrows.min(ncols), U1) }; if nrows.value() == 0 || ncols.value() == 0 { - return QR { qr: m, tau: tau }; + return Self { qr: m, tau: tau }; } let lwork = N::xgeqrf_work_size( @@ -86,7 +86,7 @@ where DefaultAllocator: Allocator &mut info, ); - QR { qr: m, tau: tau } + Self { qr: m, tau: tau } } /// Retrieves the upper trapezoidal submatrix `R` of this decomposition. diff --git a/nalgebra-lapack/src/symmetric_eigen.rs b/nalgebra-lapack/src/symmetric_eigen.rs index e7d5bd0f..48e444ba 100644 --- a/nalgebra-lapack/src/symmetric_eigen.rs +++ b/nalgebra-lapack/src/symmetric_eigen.rs @@ -62,7 +62,7 @@ where DefaultAllocator: Allocator + Allocator pub fn new(m: MatrixN) -> Self { let (vals, vecs) = Self::do_decompose(m, true).expect("SymmetricEigen: convergence failure."); - SymmetricEigen { + Self { eigenvalues: vals, eigenvectors: vecs.unwrap(), } diff --git a/src/base/dimension.rs b/src/base/dimension.rs index 9ba509b9..5d1d1bd9 100644 --- a/src/base/dimension.rs +++ b/src/base/dimension.rs @@ -22,8 +22,8 @@ pub struct Dynamic { impl Dynamic { /// A dynamic size equal to `value`. #[inline] - pub fn new(value: usize) -> Dynamic { - Dynamic { value: value } + pub fn new(value: usize) -> Self { + Self { value: value } } } @@ -80,7 +80,7 @@ impl Dim for Dynamic { #[inline] fn from_usize(dim: usize) -> Self { - Dynamic::new(dim) + Self::new(dim) } #[inline] @@ -93,8 +93,8 @@ impl Add for Dynamic { type Output = Dynamic; #[inline] - fn add(self, rhs: usize) -> Dynamic { - Dynamic::new(self.value + rhs) + fn add(self, rhs: usize) -> Self { + Self::new(self.value + rhs) } } @@ -102,8 +102,8 @@ impl Sub for Dynamic { type Output = Dynamic; #[inline] - fn sub(self, rhs: usize) -> Dynamic { - Dynamic::new(self.value - rhs) + fn sub(self, rhs: usize) -> Self { + Self::new(self.value - rhs) } } diff --git a/src/base/matrix.rs b/src/base/matrix.rs index cb687983..fcd53703 100644 --- a/src/base/matrix.rs +++ b/src/base/matrix.rs @@ -152,7 +152,7 @@ impl Matrix { impl> Matrix { /// Creates a new matrix with the given data. #[inline] - pub fn from_data(data: S) -> Matrix { + pub fn from_data(data: S) -> Self { unsafe { Self::from_data_statically_unchecked(data) } } diff --git a/src/base/matrix_alga.rs b/src/base/matrix_alga.rs index 427cdc84..6ce60809 100644 --- a/src/base/matrix_alga.rs +++ b/src/base/matrix_alga.rs @@ -51,7 +51,7 @@ where DefaultAllocator: Allocator, { #[inline] - fn two_sided_inverse(&self) -> MatrixMN { + fn two_sided_inverse(&self) -> Self { -self } @@ -203,7 +203,7 @@ impl FiniteDimInnerSpace for MatrixMN where DefaultAllocator: Allocator { #[inline] - fn orthonormalize(vs: &mut [MatrixMN]) -> usize { + fn orthonormalize(vs: &mut [Self]) -> usize { let mut nbasis_elements = 0; for i in 0..vs.len() { diff --git a/src/base/matrix_slice.rs b/src/base/matrix_slice.rs index d26fffb6..a4ce1533 100644 --- a/src/base/matrix_slice.rs +++ b/src/base/matrix_slice.rs @@ -99,7 +99,7 @@ impl<'a, N: Scalar, R: Dim, C: Dim, RStride: Dim, CStride: Dim> Clone { #[inline] fn clone(&self) -> Self { - SliceStorage { + Self { ptr: self.ptr, shape: self.shape, strides: self.strides, diff --git a/src/base/ops.rs b/src/base/ops.rs index 8167dd86..96d4626f 100644 --- a/src/base/ops.rs +++ b/src/base/ops.rs @@ -24,7 +24,7 @@ impl> Index for Matrix &N { + fn index(&self, i: usize) -> &Self::Output { let ij = self.vector_to_matrix_index(i); &self[ij] } @@ -38,7 +38,7 @@ where type Output = N; #[inline] - fn index(&self, ij: (usize, usize)) -> &N { + fn index(&self, ij: (usize, usize)) -> &Self::Output { let shape = self.shape(); assert!( ij.0 < shape.0 && ij.1 < shape.1, diff --git a/src/base/vec_storage.rs b/src/base/vec_storage.rs index 4a852f25..afde3677 100644 --- a/src/base/vec_storage.rs +++ b/src/base/vec_storage.rs @@ -36,12 +36,12 @@ pub type MatrixVec = VecStorage; impl VecStorage { /// Creates a new dynamic matrix data storage from the given vector and shape. #[inline] - pub fn new(nrows: R, ncols: C, data: Vec) -> VecStorage { + pub fn new(nrows: R, ncols: C, data: Vec) -> Self { assert!( nrows.value() * ncols.value() == data.len(), "Data storage buffer dimension mismatch." ); - VecStorage { + Self { data: data, nrows: nrows, ncols: ncols, diff --git a/src/geometry/isometry.rs b/src/geometry/isometry.rs index 1097be47..0d3c6619 100644 --- a/src/geometry/isometry.rs +++ b/src/geometry/isometry.rs @@ -100,7 +100,7 @@ where DefaultAllocator: Allocator { #[inline] fn clone(&self) -> Self { - Isometry::from_parts(self.translation.clone(), self.rotation.clone()) + Self::from_parts(self.translation.clone(), self.rotation.clone()) } } @@ -122,8 +122,8 @@ where DefaultAllocator: Allocator /// assert_relative_eq!(iso * Point3::new(1.0, 2.0, 3.0), Point3::new(-1.0, 2.0, 0.0), epsilon = 1.0e-6); /// ``` #[inline] - pub fn from_parts(translation: Translation, rotation: R) -> Isometry { - Isometry { + pub fn from_parts(translation: Translation, rotation: R) -> Self { + Self { rotation: rotation, translation: translation, _noconstruct: PhantomData, @@ -144,7 +144,7 @@ where DefaultAllocator: Allocator /// assert_eq!(inv * (iso * pt), pt); /// ``` #[inline] - pub fn inverse(&self) -> Isometry { + pub fn inverse(&self) -> Self { let mut res = self.clone(); res.inverse_mut(); res @@ -306,7 +306,7 @@ where DefaultAllocator: Allocator, { #[inline] - fn eq(&self, right: &Isometry) -> bool { + fn eq(&self, right: &Self) -> bool { self.translation == right.translation && self.rotation == right.rotation } } diff --git a/src/geometry/isometry_alga.rs b/src/geometry/isometry_alga.rs index fee8b63d..246947ca 100644 --- a/src/geometry/isometry_alga.rs +++ b/src/geometry/isometry_alga.rs @@ -121,7 +121,7 @@ where type Translation = Translation; #[inline] - fn decompose(&self) -> (Translation, R, Id, R) { + fn decompose(&self) -> (Self::Translation, R, Id, R) { ( self.translation.clone(), self.rotation.clone(), diff --git a/src/geometry/orthographic.rs b/src/geometry/orthographic.rs index c6c5628b..3117c1b6 100644 --- a/src/geometry/orthographic.rs +++ b/src/geometry/orthographic.rs @@ -26,7 +26,7 @@ impl Copy for Orthographic3 {} impl Clone for Orthographic3 { #[inline] fn clone(&self) -> Self { - Orthographic3::from_matrix_unchecked(self.matrix.clone()) + Self::from_matrix_unchecked(self.matrix.clone()) } } @@ -57,7 +57,7 @@ impl<'a, N: Real + Deserialize<'a>> Deserialize<'a> for Orthographic3 { where Des: Deserializer<'a> { let matrix = Matrix4::::deserialize(deserializer)?; - Ok(Orthographic3::from_matrix_unchecked(matrix)) + Ok(Self::from_matrix_unchecked(matrix)) } } @@ -135,7 +135,7 @@ impl Orthographic3 { /// ``` #[inline] pub fn from_matrix_unchecked(matrix: Matrix4) -> Self { - Orthographic3 { matrix: matrix } + Self { matrix: matrix } } /// Creates a new orthographic projection matrix from an aspect ratio and the vertical field of view. diff --git a/src/geometry/perspective.rs b/src/geometry/perspective.rs index b7e0d8ea..550469be 100644 --- a/src/geometry/perspective.rs +++ b/src/geometry/perspective.rs @@ -27,7 +27,7 @@ impl Copy for Perspective3 {} impl Clone for Perspective3 { #[inline] fn clone(&self) -> Self { - Perspective3::from_matrix_unchecked(self.matrix.clone()) + Self::from_matrix_unchecked(self.matrix.clone()) } } @@ -58,7 +58,7 @@ impl<'a, N: Real + Deserialize<'a>> Deserialize<'a> for Perspective3 { where Des: Deserializer<'a> { let matrix = Matrix4::::deserialize(deserializer)?; - Ok(Perspective3::from_matrix_unchecked(matrix)) + Ok(Self::from_matrix_unchecked(matrix)) } } @@ -75,7 +75,7 @@ impl Perspective3 { ); let matrix = Matrix4::identity(); - let mut res = Perspective3::from_matrix_unchecked(matrix); + let mut res = Self::from_matrix_unchecked(matrix); res.set_fovy(fovy); res.set_aspect(aspect); @@ -93,7 +93,7 @@ impl Perspective3 { /// projection. #[inline] pub fn from_matrix_unchecked(matrix: Matrix4) -> Self { - Perspective3 { matrix: matrix } + Self { matrix: matrix } } /// Retrieves the inverse of the underlying homogeneous matrix. diff --git a/src/geometry/point.rs b/src/geometry/point.rs index 0d24ab1f..14ce7dc2 100644 --- a/src/geometry/point.rs +++ b/src/geometry/point.rs @@ -66,7 +66,7 @@ where where Des: Deserializer<'a> { let coords = VectorN::::deserialize(deserializer)?; - Ok(Point::from(coords)) + Ok(Self::from(coords)) } } @@ -126,8 +126,8 @@ where DefaultAllocator: Allocator /// Creates a new point with the given coordinates. #[deprecated(note = "Use Point::from(vector) instead.")] #[inline] - pub fn from_coordinates(coords: VectorN) -> Point { - Point { coords: coords } + pub fn from_coordinates(coords: VectorN) -> Self { + Self { coords: coords } } /// The dimension of this point. diff --git a/src/geometry/point_alga.rs b/src/geometry/point_alga.rs index 56940dd1..2f81ceff 100644 --- a/src/geometry/point_alga.rs +++ b/src/geometry/point_alga.rs @@ -54,7 +54,7 @@ where { #[inline] fn meet(&self, other: &Self) -> Self { - Point::from(self.coords.meet(&other.coords)) + Self::from(self.coords.meet(&other.coords)) } } @@ -65,7 +65,7 @@ where { #[inline] fn join(&self, other: &Self) -> Self { - Point::from(self.coords.join(&other.coords)) + Self::from(self.coords.join(&other.coords)) } } @@ -78,6 +78,6 @@ where fn meet_join(&self, other: &Self) -> (Self, Self) { let (meet, join) = self.coords.meet_join(&other.coords); - (Point::from(meet), Point::from(join)) + (Self::from(meet), Self::from(join)) } } diff --git a/src/geometry/point_construction.rs b/src/geometry/point_construction.rs index 2c030f61..b6c46779 100644 --- a/src/geometry/point_construction.rs +++ b/src/geometry/point_construction.rs @@ -145,7 +145,7 @@ where { #[inline] fn arbitrary(g: &mut G) -> Self { - Point::from(VectorN::arbitrary(g)) + Self::from(VectorN::arbitrary(g)) } } @@ -163,7 +163,7 @@ macro_rules! componentwise_constructors_impl( #[doc = $doc] #[doc = "```"] #[inline] - pub fn new($($args: N),*) -> Point { + pub fn new($($args: N),*) -> Self { unsafe { let mut res = Self::new_uninitialized(); $( *res.get_unchecked_mut($irow) = $args; )* @@ -194,7 +194,7 @@ macro_rules! from_array_impl( ($($D: ty, $len: expr);*) => {$( impl From<[N; $len]> for Point { fn from (coords: [N; $len]) -> Self { - Point { + Self { coords: coords.into() } } diff --git a/src/geometry/point_conversion.rs b/src/geometry/point_conversion.rs index 84efab6d..50a3a4d2 100644 --- a/src/geometry/point_conversion.rs +++ b/src/geometry/point_conversion.rs @@ -45,7 +45,7 @@ where #[inline] unsafe fn from_superset_unchecked(m: &Point) -> Self { - Point::from(Matrix::from_superset_unchecked(&m.coords)) + Self::from(Matrix::from_superset_unchecked(&m.coords)) } } diff --git a/src/geometry/point_ops.rs b/src/geometry/point_ops.rs index a923fbf9..0a20bc90 100644 --- a/src/geometry/point_ops.rs +++ b/src/geometry/point_ops.rs @@ -46,11 +46,11 @@ where DefaultAllocator: Allocator impl Neg for Point where DefaultAllocator: Allocator { - type Output = Point; + type Output = Self; #[inline] fn neg(self) -> Self::Output { - Point::from(-self.coords) + Self::Output::from(-self.coords) } } @@ -61,7 +61,7 @@ where DefaultAllocator: Allocator #[inline] fn neg(self) -> Self::Output { - Point::from(-&self.coords) + Self::Output::from(-&self.coords) } } diff --git a/src/geometry/quaternion.rs b/src/geometry/quaternion.rs index 96e4f19a..b58d885c 100644 --- a/src/geometry/quaternion.rs +++ b/src/geometry/quaternion.rs @@ -68,7 +68,7 @@ impl Copy for Quaternion {} impl Clone for Quaternion { #[inline] fn clone(&self) -> Self { - Quaternion::from(self.coords.clone()) + Self::from(self.coords.clone()) } } @@ -90,7 +90,7 @@ where Owned: Deserialize<'a> where Des: Deserializer<'a> { let coords = Vector4::::deserialize(deserializer)?; - Ok(Quaternion::from(coords)) + Ok(Self::from(coords)) } } @@ -98,15 +98,15 @@ impl Quaternion { /// Moves this unit quaternion into one that owns its data. #[inline] #[deprecated(note = "This method is a no-op and will be removed in a future release.")] - pub fn into_owned(self) -> Quaternion { + pub fn into_owned(self) -> Self { self } /// Clones this unit quaternion into one that owns its data. #[inline] #[deprecated(note = "This method is a no-op and will be removed in a future release.")] - pub fn clone_owned(&self) -> Quaternion { - Quaternion::from(self.coords.clone_owned()) + pub fn clone_owned(&self) -> Self { + Self::from(self.coords.clone_owned()) } /// Normalizes this quaternion. @@ -120,8 +120,8 @@ impl Quaternion { /// relative_eq!(q_normalized.norm(), 1.0); /// ``` #[inline] - pub fn normalize(&self) -> Quaternion { - Quaternion::from(self.coords.normalize()) + pub fn normalize(&self) -> Self { + Self::from(self.coords.normalize()) } /// The conjugate of this quaternion. @@ -134,14 +134,14 @@ impl Quaternion { /// assert!(conj.i == -2.0 && conj.j == -3.0 && conj.k == -4.0 && conj.w == 1.0); /// ``` #[inline] - pub fn conjugate(&self) -> Quaternion { + pub fn conjugate(&self) -> Self { let v = Vector4::new( -self.coords[0], -self.coords[1], -self.coords[2], self.coords[3], ); - Quaternion::from(v) + Self::from(v) } /// Inverts this quaternion if it is not zero. @@ -163,8 +163,8 @@ impl Quaternion { /// assert!(inv_q.is_none()); /// ``` #[inline] - pub fn try_inverse(&self) -> Option> { - let mut res = Quaternion::from(self.coords.clone_owned()); + pub fn try_inverse(&self) -> Option { + let mut res = Self::from(self.coords.clone_owned()); if res.try_inverse_mut() { Some(res) @@ -186,7 +186,7 @@ impl Quaternion { /// assert_eq!(q1.lerp(&q2, 0.1), Quaternion::new(1.9, 3.8, 5.7, 7.6)); /// ``` #[inline] - pub fn lerp(&self, other: &Quaternion, t: N) -> Quaternion { + pub fn lerp(&self, other: &Self, t: N) -> Self { self * (N::one() - t) + other * t } @@ -346,12 +346,12 @@ impl Quaternion { /// assert_relative_eq!(q.ln(), Quaternion::new(1.683647, 1.190289, 0.0, 0.0), epsilon = 1.0e-6) /// ``` #[inline] - pub fn ln(&self) -> Quaternion { + pub fn ln(&self) -> Self { let n = self.norm(); let v = self.vector(); let s = self.scalar(); - Quaternion::from_parts(n.ln(), v.normalize() * (s / n).acos()) + Self::from_parts(n.ln(), v.normalize() * (s / n).acos()) } /// Compute the exponential of a quaternion. @@ -364,7 +364,7 @@ impl Quaternion { /// assert_relative_eq!(q.exp(), Quaternion::new(2.0, 5.0, 0.0, 0.0), epsilon = 1.0e-5) /// ``` #[inline] - pub fn exp(&self) -> Quaternion { + pub fn exp(&self) -> Self { self.exp_eps(N::default_epsilon()) } @@ -383,18 +383,18 @@ impl Quaternion { /// assert_eq!(q.exp_eps(1.0e-6), Quaternion::identity()); /// ``` #[inline] - pub fn exp_eps(&self, eps: N) -> Quaternion { + pub fn exp_eps(&self, eps: N) -> Self { let v = self.vector(); let nn = v.norm_squared(); if nn <= eps * eps { - Quaternion::identity() + Self::identity() } else { let w_exp = self.scalar().exp(); let n = nn.sqrt(); let nv = v * (w_exp * n.sin() / n); - Quaternion::from_parts(w_exp * n.cos(), nv) + Self::from_parts(w_exp * n.cos(), nv) } } @@ -408,7 +408,7 @@ impl Quaternion { /// assert_relative_eq!(q.powf(1.5), Quaternion::new( -6.2576659, 4.1549037, 6.2323556, 8.3098075), epsilon = 1.0e-6); /// ``` #[inline] - pub fn powf(&self, n: N) -> Quaternion { + pub fn powf(&self, n: N) -> Self { (self.ln() * n).exp() } @@ -520,7 +520,7 @@ impl> AbsDiffEq for Quaternion { fn abs_diff_eq(&self, other: &Self, epsilon: Self::Epsilon) -> bool { self.as_vector().abs_diff_eq(other.as_vector(), epsilon) || // Account for the double-covering of S², i.e. q = -q - self.as_vector().iter().zip(other.as_vector().iter()).all(|(a, b)| a.abs_diff_eq(&-*b, epsilon)) + self.as_vector().iter().zip(other.as_vector().iter()).all(|(a, b)| a.abs_diff_eq(&-*b, epsilon)) } } @@ -540,7 +540,7 @@ impl> RelativeEq for Quaternion { { self.as_vector().relative_eq(other.as_vector(), epsilon, max_relative) || // Account for the double-covering of S², i.e. q = -q - self.as_vector().iter().zip(other.as_vector().iter()).all(|(a, b)| a.relative_eq(&-*b, epsilon, max_relative)) + self.as_vector().iter().zip(other.as_vector().iter()).all(|(a, b)| a.relative_eq(&-*b, epsilon, max_relative)) } } @@ -554,7 +554,7 @@ impl> UlpsEq for Quaternion { fn ulps_eq(&self, other: &Self, epsilon: Self::Epsilon, max_ulps: u32) -> bool { self.as_vector().ulps_eq(other.as_vector(), epsilon, max_ulps) || // Account for the double-covering of S², i.e. q = -q. - self.as_vector().iter().zip(other.as_vector().iter()).all(|(a, b)| a.ulps_eq(&-*b, epsilon, max_ulps)) + self.as_vector().iter().zip(other.as_vector().iter()).all(|(a, b)| a.ulps_eq(&-*b, epsilon, max_ulps)) } } @@ -577,7 +577,7 @@ impl UnitQuaternion { #[deprecated( note = "This method is unnecessary and will be removed in a future release. Use `.clone()` instead." )] - pub fn into_owned(self) -> UnitQuaternion { + pub fn into_owned(self) -> Self { self } @@ -586,7 +586,7 @@ impl UnitQuaternion { #[deprecated( note = "This method is unnecessary and will be removed in a future release. Use `.clone()` instead." )] - pub fn clone_owned(&self) -> UnitQuaternion { + pub fn clone_owned(&self) -> Self { *self } @@ -637,8 +637,8 @@ impl UnitQuaternion { /// assert_eq!(conj, UnitQuaternion::from_axis_angle(&-axis, 1.78)); /// ``` #[inline] - pub fn conjugate(&self) -> UnitQuaternion { - UnitQuaternion::new_unchecked(self.as_ref().conjugate()) + pub fn conjugate(&self) -> Self { + Self::new_unchecked(self.as_ref().conjugate()) } /// Inverts this quaternion if it is not zero. @@ -653,7 +653,7 @@ impl UnitQuaternion { /// assert_eq!(inv * rot, UnitQuaternion::identity()); /// ``` #[inline] - pub fn inverse(&self) -> UnitQuaternion { + pub fn inverse(&self) -> Self { self.conjugate() } @@ -668,7 +668,7 @@ impl UnitQuaternion { /// assert_relative_eq!(rot1.angle_to(&rot2), 1.0045657, epsilon = 1.0e-6); /// ``` #[inline] - pub fn angle_to(&self, other: &UnitQuaternion) -> N { + pub fn angle_to(&self, other: &Self) -> N { let delta = self.rotation_to(other); delta.angle() } @@ -687,7 +687,7 @@ impl UnitQuaternion { /// assert_relative_eq!(rot_to * rot1, rot2, epsilon = 1.0e-6); /// ``` #[inline] - pub fn rotation_to(&self, other: &UnitQuaternion) -> UnitQuaternion { + pub fn rotation_to(&self, other: &Self) -> Self{ other / self } @@ -703,7 +703,7 @@ impl UnitQuaternion { /// assert_eq!(q1.lerp(&q2, 0.1), Quaternion::new(0.9, 0.1, 0.0, 0.0)); /// ``` #[inline] - pub fn lerp(&self, other: &UnitQuaternion, t: N) -> Quaternion { + pub fn lerp(&self, other: &Self, t: N) -> Quaternion { self.as_ref().lerp(other.as_ref(), t) } @@ -719,11 +719,11 @@ impl UnitQuaternion { /// assert_eq!(q1.nlerp(&q2, 0.1), UnitQuaternion::new_normalize(Quaternion::new(0.9, 0.1, 0.0, 0.0))); /// ``` #[inline] - pub fn nlerp(&self, other: &UnitQuaternion, t: N) -> UnitQuaternion { + pub fn nlerp(&self, other: &Self, t: N) -> Self { let mut res = self.lerp(other, t); let _ = res.normalize_mut(); - UnitQuaternion::new_unchecked(res) + Self::new_unchecked(res) } /// Spherical linear interpolation between two unit quaternions. @@ -731,7 +731,7 @@ impl UnitQuaternion { /// Panics if the angle between both quaternion is 180 degrees (in which case the interpolation /// is not well-defined). Use `.try_slerp` instead to avoid the panic. #[inline] - pub fn slerp(&self, other: &UnitQuaternion, t: N) -> UnitQuaternion { + pub fn slerp(&self, other: &Self, t: N) -> Self { Unit::new_unchecked(Quaternion::from( Unit::new_unchecked(self.coords) .slerp(&Unit::new_unchecked(other.coords), t) @@ -752,10 +752,10 @@ impl UnitQuaternion { #[inline] pub fn try_slerp( &self, - other: &UnitQuaternion, + other: &Self, t: N, epsilon: N, - ) -> Option> + ) -> Option { Unit::new_unchecked(self.coords) .try_slerp(&Unit::new_unchecked(other.coords), t, epsilon) @@ -902,11 +902,11 @@ impl UnitQuaternion { /// assert_eq!(pow.angle(), 2.4); /// ``` #[inline] - pub fn powf(&self, n: N) -> UnitQuaternion { + pub fn powf(&self, n: N) -> Self { if let Some(v) = self.axis() { - UnitQuaternion::from_axis_angle(&v, self.angle() * n) + Self::from_axis_angle(&v, self.angle() * n) } else { - UnitQuaternion::identity() + Self::identity() } } diff --git a/src/geometry/quaternion_construction.rs b/src/geometry/quaternion_construction.rs index 257cb719..4098a5da 100644 --- a/src/geometry/quaternion_construction.rs +++ b/src/geometry/quaternion_construction.rs @@ -25,7 +25,7 @@ impl Quaternion { #[inline] #[deprecated(note = "Use `::from` instead.")] pub fn from_vector(vector: Vector4) -> Self { - Quaternion { coords: vector } + Self { coords: vector } } /// Creates a new quaternion from its individual components. Note that the arguments order does @@ -130,7 +130,7 @@ where Owned: Send { #[inline] fn arbitrary(g: &mut G) -> Self { - Quaternion::new( + Self::new( N::arbitrary(g), N::arbitrary(g), N::arbitrary(g), @@ -683,7 +683,7 @@ where #[inline] fn arbitrary(g: &mut G) -> Self { let axisangle = Vector3::arbitrary(g); - UnitQuaternion::from_scaled_axis(axisangle) + Self::from_scaled_axis(axisangle) } } diff --git a/src/geometry/quaternion_conversion.rs b/src/geometry/quaternion_conversion.rs index c2d70726..741c68da 100644 --- a/src/geometry/quaternion_conversion.rs +++ b/src/geometry/quaternion_conversion.rs @@ -103,7 +103,7 @@ impl SubsetOf> for UnitQuaternion where N1: Real, N2: Real + SupersetOf, - R: AlgaRotation> + SupersetOf>, + R: AlgaRotation> + SupersetOf, { #[inline] fn to_superset(&self) -> Isometry { @@ -125,7 +125,7 @@ impl SubsetOf> for UnitQuaternion where N1: Real, N2: Real + SupersetOf, - R: AlgaRotation> + SupersetOf>, + R: AlgaRotation> + SupersetOf, { #[inline] fn to_superset(&self) -> Similarity { @@ -186,7 +186,7 @@ impl> SubsetOf> for UnitQuaterni #[cfg(feature = "mint")] impl From> for Quaternion { fn from(q: mint::Quaternion) -> Self { - Quaternion::new(q.s, q.v.x, q.v.y, q.v.z) + Self::new(q.s, q.v.x, q.v.y, q.v.z) } } @@ -220,14 +220,14 @@ impl Into> for UnitQuaternion { impl From> for Matrix4 { #[inline] - fn from(q: UnitQuaternion) -> Matrix4 { + fn from(q: UnitQuaternion) -> Self { q.to_homogeneous() } } impl From> for Matrix3 { #[inline] - fn from(q: UnitQuaternion) -> Matrix3 { + fn from(q: UnitQuaternion) -> Self { q.to_rotation_matrix().into_inner() } } @@ -235,6 +235,6 @@ impl From> for Matrix3 { impl From> for Quaternion { #[inline] fn from(coords: Vector4) -> Self { - Quaternion { coords } + Self { coords } } } diff --git a/src/geometry/quaternion_ops.rs b/src/geometry/quaternion_ops.rs index 842b4edd..2ed72453 100644 --- a/src/geometry/quaternion_ops.rs +++ b/src/geometry/quaternion_ops.rs @@ -67,7 +67,7 @@ impl Index for Quaternion { type Output = N; #[inline] - fn index(&self, i: usize) -> &N { + fn index(&self, i: usize) -> &Self::Output { &self.coords[i] } } diff --git a/src/geometry/reflection.rs b/src/geometry/reflection.rs index fa08dcdd..6b668c6f 100644 --- a/src/geometry/reflection.rs +++ b/src/geometry/reflection.rs @@ -18,8 +18,8 @@ impl> Reflection { /// /// The bias is the position of the plane on the axis. In particular, a bias equal to zero /// represents a plane that passes through the origin. - pub fn new(axis: Unit>, bias: N) -> Reflection { - Reflection { + pub fn new(axis: Unit>, bias: N) -> Self { + Self { axis: axis.into_inner(), bias: bias, } @@ -30,7 +30,7 @@ impl> Reflection { pub fn new_containing_point( axis: Unit>, pt: &Point, - ) -> Reflection + ) -> Self where D: DimName, DefaultAllocator: Allocator, diff --git a/src/geometry/rotation.rs b/src/geometry/rotation.rs index 6c50230e..ca9d888f 100644 --- a/src/geometry/rotation.rs +++ b/src/geometry/rotation.rs @@ -53,7 +53,7 @@ where { #[inline] fn clone(&self) -> Self { - Rotation::from_matrix_unchecked(self.matrix.clone()) + Self::from_matrix_unchecked(self.matrix.clone()) } } @@ -100,7 +100,7 @@ where where Des: Deserializer<'a> { let matrix = MatrixN::::deserialize(deserializer)?; - Ok(Rotation::from_matrix_unchecked(matrix)) + Ok(Self::from_matrix_unchecked(matrix)) } } @@ -241,13 +241,13 @@ where DefaultAllocator: Allocator /// assert_eq!(*rot.matrix(), mat); /// ``` #[inline] - pub fn from_matrix_unchecked(matrix: MatrixN) -> Rotation { + pub fn from_matrix_unchecked(matrix: MatrixN) -> Self { assert!( matrix.is_square(), "Unable to create a rotation from a non-square matrix." ); - Rotation { matrix: matrix } + Self { matrix: matrix } } /// Transposes `self`. @@ -269,8 +269,8 @@ where DefaultAllocator: Allocator /// assert_relative_eq!(tr_rot * rot, Rotation2::identity(), epsilon = 1.0e-6); /// ``` #[inline] - pub fn transpose(&self) -> Rotation { - Rotation::from_matrix_unchecked(self.matrix.transpose()) + pub fn transpose(&self) -> Self { + Self::from_matrix_unchecked(self.matrix.transpose()) } /// Inverts `self`. @@ -292,7 +292,7 @@ where DefaultAllocator: Allocator /// assert_relative_eq!(inv * rot, Rotation2::identity(), epsilon = 1.0e-6); /// ``` #[inline] - pub fn inverse(&self) -> Rotation { + pub fn inverse(&self) -> Self { self.transpose() } @@ -357,7 +357,7 @@ impl PartialEq for Rotation where DefaultAllocator: Allocator { #[inline] - fn eq(&self, right: &Rotation) -> bool { + fn eq(&self, right: &Self) -> bool { self.matrix == right.matrix } } diff --git a/src/geometry/rotation_conversion.rs b/src/geometry/rotation_conversion.rs index 3b574041..044d85af 100644 --- a/src/geometry/rotation_conversion.rs +++ b/src/geometry/rotation_conversion.rs @@ -102,7 +102,7 @@ impl SubsetOf> for Rotation where N1: Real, N2: Real + SupersetOf, - R: AlgaRotation> + SupersetOf>, + R: AlgaRotation> + SupersetOf, DefaultAllocator: Allocator + Allocator, { #[inline] @@ -125,7 +125,7 @@ impl SubsetOf> for Rotation where N1: Real, N2: Real + SupersetOf, - R: AlgaRotation> + SupersetOf>, + R: AlgaRotation> + SupersetOf, DefaultAllocator: Allocator + Allocator, { #[inline] @@ -219,28 +219,28 @@ impl From> for Rotation3 { impl From> for Matrix3 { #[inline] - fn from(q: Rotation2) -> Matrix3 { + fn from(q: Rotation2) ->Self { q.to_homogeneous() } } impl From> for Matrix2 { #[inline] - fn from(q: Rotation2) -> Matrix2 { + fn from(q: Rotation2) -> Self { q.into_inner() } } impl From> for Matrix4 { #[inline] - fn from(q: Rotation3) -> Matrix4 { + fn from(q: Rotation3) -> Self { q.to_homogeneous() } } impl From> for Matrix3 { #[inline] - fn from(q: Rotation3) -> Matrix3 { + fn from(q: Rotation3) -> Self { q.into_inner() } } diff --git a/src/geometry/rotation_specialization.rs b/src/geometry/rotation_specialization.rs index 35ae1ea2..dde5bb82 100644 --- a/src/geometry/rotation_specialization.rs +++ b/src/geometry/rotation_specialization.rs @@ -125,7 +125,7 @@ impl Rotation2 { /// assert_relative_eq!(rot1.angle_to(&rot2), 1.6); /// ``` #[inline] - pub fn angle_to(&self, other: &Rotation2) -> N { + pub fn angle_to(&self, other: &Self) -> N { self.rotation_to(other).angle() } @@ -145,7 +145,7 @@ impl Rotation2 { /// assert_relative_eq!(rot_to.inverse() * rot2, rot1); /// ``` #[inline] - pub fn rotation_to(&self, other: &Rotation2) -> Rotation2 { + pub fn rotation_to(&self, other: &Self) -> Self { other * self.inverse() } @@ -161,7 +161,7 @@ impl Rotation2 { /// assert_relative_eq!(pow.angle(), 2.0 * 0.78); /// ``` #[inline] - pub fn powf(&self, n: N) -> Rotation2 { + pub fn powf(&self, n: N) -> Self { Self::new(self.angle() * n) } @@ -655,7 +655,7 @@ impl Rotation3 { /// assert_relative_eq!(rot1.angle_to(&rot2), 1.0045657, epsilon = 1.0e-6); /// ``` #[inline] - pub fn angle_to(&self, other: &Rotation3) -> N { + pub fn angle_to(&self, other: &Self) -> N { self.rotation_to(other).angle() } @@ -673,7 +673,7 @@ impl Rotation3 { /// assert_relative_eq!(rot_to * rot1, rot2, epsilon = 1.0e-6); /// ``` #[inline] - pub fn rotation_to(&self, other: &Rotation3) -> Rotation3 { + pub fn rotation_to(&self, other: &Self) -> Self { other * self.inverse() } @@ -692,7 +692,7 @@ impl Rotation3 { /// assert_eq!(pow.angle(), 2.4); /// ``` #[inline] - pub fn powf(&self, n: N) -> Rotation3 { + pub fn powf(&self, n: N) -> Self { if let Some(axis) = self.axis() { Self::from_axis_angle(&axis, self.angle() * n) } else if self.matrix()[(0, 0)] < N::zero() { diff --git a/src/geometry/similarity.rs b/src/geometry/similarity.rs index f321d575..1d2f50b4 100644 --- a/src/geometry/similarity.rs +++ b/src/geometry/similarity.rs @@ -106,20 +106,20 @@ where translation: Translation, rotation: R, scaling: N, - ) -> Similarity + ) -> Self { - Similarity::from_isometry(Isometry::from_parts(translation, rotation), scaling) + Self::from_isometry(Isometry::from_parts(translation, rotation), scaling) } /// Creates a new similarity from its rotational and translational parts. #[inline] - pub fn from_isometry(isometry: Isometry, scaling: N) -> Similarity { + pub fn from_isometry(isometry: Isometry, scaling: N) -> Self { assert!( !relative_eq!(scaling, N::zero()), "The scaling factor must not be zero." ); - Similarity { + Self { isometry: isometry, scaling: scaling, } @@ -127,13 +127,13 @@ where /// Creates a new similarity that applies only a scaling factor. #[inline] - pub fn from_scaling(scaling: N) -> Similarity { + pub fn from_scaling(scaling: N) -> Self { Self::from_isometry(Isometry::identity(), scaling) } /// Inverts `self`. #[inline] - pub fn inverse(&self) -> Similarity { + pub fn inverse(&self) -> Self { let mut res = self.clone(); res.inverse_mut(); res @@ -277,7 +277,7 @@ where DefaultAllocator: Allocator, { #[inline] - fn eq(&self, right: &Similarity) -> bool { + fn eq(&self, right: &Self) -> bool { self.isometry == right.isometry && self.scaling == right.scaling } } diff --git a/src/geometry/transform_conversion.rs b/src/geometry/transform_conversion.rs index 0ab96221..ab5ad5df 100644 --- a/src/geometry/transform_conversion.rs +++ b/src/geometry/transform_conversion.rs @@ -57,7 +57,7 @@ where #[inline] unsafe fn from_superset_unchecked(m: &MatrixN>) -> Self { - Transform::from_matrix_unchecked(::convert_ref_unchecked(m)) + Self::from_matrix_unchecked(::convert_ref_unchecked(m)) } } diff --git a/src/geometry/unit_complex.rs b/src/geometry/unit_complex.rs index f8d94dc8..cae41483 100644 --- a/src/geometry/unit_complex.rs +++ b/src/geometry/unit_complex.rs @@ -108,7 +108,7 @@ impl UnitComplex { /// ``` #[inline] pub fn conjugate(&self) -> Self { - UnitComplex::new_unchecked(self.conj()) + Self::new_unchecked(self.conj()) } /// Inverts this complex number if it is not zero. @@ -314,7 +314,7 @@ impl From> for Matrix3 { impl From> for Matrix2 { #[inline] - fn from(q: UnitComplex) -> Matrix2 { + fn from(q: UnitComplex) -> Self { q.to_rotation_matrix().into_inner() } } diff --git a/src/geometry/unit_complex_construction.rs b/src/geometry/unit_complex_construction.rs index c4c9cc0d..37518b4f 100644 --- a/src/geometry/unit_complex_construction.rs +++ b/src/geometry/unit_complex_construction.rs @@ -85,7 +85,7 @@ impl UnitComplex { /// ``` #[inline] pub fn from_cos_sin_unchecked(cos: N, sin: N) -> Self { - UnitComplex::new_unchecked(Complex::new(cos, sin)) + Self::new_unchecked(Complex::new(cos, sin)) } /// Builds a unit complex rotation from an angle in radian wrapped in a 1-dimensional vector. diff --git a/src/geometry/unit_complex_conversion.rs b/src/geometry/unit_complex_conversion.rs index ee0ed5d8..fd4d1103 100644 --- a/src/geometry/unit_complex_conversion.rs +++ b/src/geometry/unit_complex_conversion.rs @@ -74,7 +74,7 @@ impl SubsetOf> for UnitComplex where N1: Real, N2: Real + SupersetOf, - R: AlgaRotation> + SupersetOf>, + R: AlgaRotation> + SupersetOf, { #[inline] fn to_superset(&self) -> Isometry { @@ -96,7 +96,7 @@ impl SubsetOf> for UnitComplex where N1: Real, N2: Real + SupersetOf, - R: AlgaRotation> + SupersetOf>, + R: AlgaRotation> + SupersetOf, { #[inline] fn to_superset(&self) -> Similarity { diff --git a/src/geometry/unit_complex_ops.rs b/src/geometry/unit_complex_ops.rs index c9d31ad4..75b45eda 100644 --- a/src/geometry/unit_complex_ops.rs +++ b/src/geometry/unit_complex_ops.rs @@ -45,11 +45,11 @@ use geometry::{Isometry, Point2, Rotation, Similarity, Translation, UnitComplex} */ // UnitComplex × UnitComplex -impl Mul> for UnitComplex { - type Output = UnitComplex; +impl Mul for UnitComplex { + type Output = Self; #[inline] - fn mul(self, rhs: UnitComplex) -> UnitComplex { + fn mul(self, rhs: Self) -> Self { Unit::new_unchecked(self.into_inner() * rhs.into_inner()) } } @@ -58,16 +58,16 @@ impl<'a, N: Real> Mul> for &'a UnitComplex { type Output = UnitComplex; #[inline] - fn mul(self, rhs: UnitComplex) -> UnitComplex { + fn mul(self, rhs: UnitComplex) -> Self::Output { Unit::new_unchecked(self.complex() * rhs.into_inner()) } } impl<'b, N: Real> Mul<&'b UnitComplex> for UnitComplex { - type Output = UnitComplex; + type Output = Self; #[inline] - fn mul(self, rhs: &'b UnitComplex) -> UnitComplex { + fn mul(self, rhs: &'b UnitComplex) -> Self::Output { Unit::new_unchecked(self.into_inner() * rhs.complex()) } } @@ -76,17 +76,17 @@ impl<'a, 'b, N: Real> Mul<&'b UnitComplex> for &'a UnitComplex { type Output = UnitComplex; #[inline] - fn mul(self, rhs: &'b UnitComplex) -> UnitComplex { + fn mul(self, rhs: &'b UnitComplex) -> Self::Output { Unit::new_unchecked(self.complex() * rhs.complex()) } } // UnitComplex ÷ UnitComplex -impl Div> for UnitComplex { - type Output = UnitComplex; +impl Div for UnitComplex { + type Output = Self; #[inline] - fn div(self, rhs: UnitComplex) -> UnitComplex { + fn div(self, rhs: Self) -> Self::Output { Unit::new_unchecked(self.into_inner() * rhs.conjugate().into_inner()) } } @@ -95,16 +95,16 @@ impl<'a, N: Real> Div> for &'a UnitComplex { type Output = UnitComplex; #[inline] - fn div(self, rhs: UnitComplex) -> UnitComplex { + fn div(self, rhs: UnitComplex) -> Self::Output { Unit::new_unchecked(self.complex() * rhs.conjugate().into_inner()) } } impl<'b, N: Real> Div<&'b UnitComplex> for UnitComplex { - type Output = UnitComplex; + type Output = Self; #[inline] - fn div(self, rhs: &'b UnitComplex) -> UnitComplex { + fn div(self, rhs: &'b UnitComplex) -> Self::Output { Unit::new_unchecked(self.into_inner() * rhs.conjugate().into_inner()) } } @@ -113,7 +113,7 @@ impl<'a, 'b, N: Real> Div<&'b UnitComplex> for &'a UnitComplex { type Output = UnitComplex; #[inline] - fn div(self, rhs: &'b UnitComplex) -> UnitComplex { + fn div(self, rhs: &'b UnitComplex) -> Self::Output { Unit::new_unchecked(self.complex() * rhs.conjugate().into_inner()) } } diff --git a/src/linalg/full_piv_lu.rs b/src/linalg/full_piv_lu.rs index 022152f4..962d4d8b 100644 --- a/src/linalg/full_piv_lu.rs +++ b/src/linalg/full_piv_lu.rs @@ -61,7 +61,7 @@ where DefaultAllocator: Allocator + Allocator<(usize, usize), DimMinimu let mut q = PermutationSequence::identity_generic(min_nrows_ncols); if min_nrows_ncols.value() == 0 { - return FullPivLU { + return Self { lu: matrix, p: p, q: q, @@ -91,7 +91,7 @@ where DefaultAllocator: Allocator + Allocator<(usize, usize), DimMinimu } } - FullPivLU { + Self { lu: matrix, p: p, q: q, diff --git a/src/linalg/permutation_sequence.rs b/src/linalg/permutation_sequence.rs index ac58d857..3aef1be6 100644 --- a/src/linalg/permutation_sequence.rs +++ b/src/linalg/permutation_sequence.rs @@ -69,7 +69,7 @@ where DefaultAllocator: Allocator<(usize, usize), D> #[inline] pub fn identity_generic(dim: D) -> Self { unsafe { - PermutationSequence { + Self { len: 0, ipiv: VectorN::new_uninitialized_generic(dim, U1), } diff --git a/src/linalg/schur.rs b/src/linalg/schur.rs index 66299c07..0d425087 100644 --- a/src/linalg/schur.rs +++ b/src/linalg/schur.rs @@ -55,7 +55,7 @@ where + Allocator, { /// Computes the Schur decomposition of a square matrix. - pub fn new(m: MatrixN) -> RealSchur { + pub fn new(m: MatrixN) -> Self { Self::try_new(m, N::default_epsilon(), 0).unwrap() } @@ -70,7 +70,7 @@ where /// * `max_niter` − maximum total number of iterations performed by the algorithm. If this /// number of iteration is exceeded, `None` is returned. If `niter == 0`, then the algorithm /// continues indefinitely until convergence. - pub fn try_new(m: MatrixN, eps: N, max_niter: usize) -> Option> { + pub fn try_new(m: MatrixN, eps: N, max_niter: usize) -> Option { let mut work = unsafe { VectorN::new_uninitialized_generic(m.data.shape().0, U1) }; Self::do_decompose(m, &mut work, eps, max_niter, true).map(|(q, t)| RealSchur { diff --git a/src/linalg/svd.rs b/src/linalg/svd.rs index 5c1d9a0f..67b49604 100644 --- a/src/linalg/svd.rs +++ b/src/linalg/svd.rs @@ -271,7 +271,7 @@ where } } - Some(SVD { + Some(Self { u: u, v_t: v_t, singular_values: b.diagonal, diff --git a/src/linalg/symmetric_tridiagonal.rs b/src/linalg/symmetric_tridiagonal.rs index 5ac75b47..2e4108ae 100644 --- a/src/linalg/symmetric_tridiagonal.rs +++ b/src/linalg/symmetric_tridiagonal.rs @@ -83,7 +83,7 @@ where DefaultAllocator: Allocator + Allocator> } } - SymmetricTridiagonal { + Self { tri: m, off_diagonal: off_diagonal, } diff --git a/src/sparse/cs_matrix.rs b/src/sparse/cs_matrix.rs index 7ddc4deb..4c2983eb 100644 --- a/src/sparse/cs_matrix.rs +++ b/src/sparse/cs_matrix.rs @@ -21,7 +21,7 @@ impl<'a, N> ColumnEntries<'a, N> { #[inline] pub fn new(i: &'a [usize], v: &'a [N]) -> Self { assert_eq!(i.len(), v.len()); - ColumnEntries { curr: 0, i, v } + Self { curr: 0, i, v } } } @@ -29,7 +29,7 @@ impl<'a, N: Copy> Iterator for ColumnEntries<'a, N> { type Item = (usize, N); #[inline] - fn next(&mut self) -> Option<(usize, N)> { + fn next(&mut self) -> Option { if self.curr >= self.i.len() { None } else { diff --git a/src/sparse/cs_matrix_ops.rs b/src/sparse/cs_matrix_ops.rs index 47804847..b944c4e2 100644 --- a/src/sparse/cs_matrix_ops.rs +++ b/src/sparse/cs_matrix_ops.rs @@ -138,7 +138,7 @@ where { type Output = CsMatrix; - fn mul(self, rhs: &'b CsMatrix) -> CsMatrix { + fn mul(self, rhs: &'b CsMatrix) -> Self::Output { let (nrows1, ncols1) = self.data.shape(); let (nrows2, ncols2) = rhs.data.shape(); assert_eq!( @@ -231,7 +231,7 @@ where { type Output = CsMatrix; - fn add(self, rhs: &'b CsMatrix) -> CsMatrix { + fn add(self, rhs: &'b CsMatrix) -> Self::Output { let (nrows1, ncols1) = self.data.shape(); let (nrows2, ncols2) = rhs.data.shape(); assert_eq!( @@ -294,7 +294,7 @@ where { type Output = Self; - fn mul(mut self, rhs: N) -> Self { + fn mul(mut self, rhs: N) -> Self::Output { for e in self.values_mut() { *e *= rhs }