From ded853757c9c4d677ae1040793833878702a637c Mon Sep 17 00:00:00 2001 From: Yuri6037 Date: Sun, 24 Oct 2021 20:31:35 +0200 Subject: [PATCH] Update src/geometry/scale.rs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Sébastien Crozet --- src/geometry/scale.rs | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/geometry/scale.rs b/src/geometry/scale.rs index 33a6bf3a..2f677d95 100755 --- a/src/geometry/scale.rs +++ b/src/geometry/scale.rs @@ -284,17 +284,15 @@ impl Scale { DefaultAllocator: Allocator, U1>, DimNameSum, U1>> + Allocator, U1>, U1>, { - // Unfortunately rust refuses at all costs to allow calling .to_homogeneous on a SVector - // (self.vector) so I had to do a manual copy in a new OVector - // The exact error is that to_homogeneous when called on a SVector requires DimAdd on Const - // not DimNameAdd which will strangely bring rust into thinking that DimNameAdd is a - // trait object and no longer a generic parameter. - let mut v = OVector::, U1>>::from_element(T::one()); + // TODO: use self.vector.push() instead. We can’t right now because + // that would require the DimAdd bound (but here we use DimNameAdd). + // This should be fixable once Rust gets a more complete support of + // const-generics. + let mut v = OVector::from_element(T::one()); for i in 0..D { - v[(i, 0)] = self.vector[(i, 0)].clone(); + v[i] = self.vector[i].clone(); } - return OMatrix::, U1>, DimNameSum, U1>>::from_diagonal(&v); - } + return OMatrix::from_diagonal(&v); /// Inverts `self` in-place. ///