From 664658760a3ec04743ad836abfdfaa60025ac877 Mon Sep 17 00:00:00 2001 From: sebcrozet Date: Thu, 13 Sep 2018 05:45:14 +0200 Subject: [PATCH] Remove the Deref implementation for MatrixRef. Fix #380. --- CHANGELOG.md | 10 +++++++--- src/base/vec_storage.rs | 14 +++++--------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fcfbfd5a..d76638f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,7 +35,8 @@ This project adheres to [Semantic Versioning](http://semver.org/). * Implement `Extend>` for matrices with dynamic storage. This will concatenate the columns of both matrices. * Implement `Into` for the `MatrixVec` storage. * Implement `Hash` for all matrices. - + * Add a `.len()` method to retrieve the size of a `MatrixVec`. + ### Modified * The orthographic projection no longer require that `bottom < top`, that `left < right`, and that `znear < zfar`. The only restriction now ith that they must not be equal (in which case the projection would be singular). @@ -46,11 +47,14 @@ This project adheres to [Semantic Versioning](http://semver.org/). * Renamed `.unwrap()` to `.into_inner()` for geometric types that wrap another type. This is for the case of `Unit`, `Transform`, `Orthographic3`, `Perspective3`, `Rotation`. * Deprecate several functions at the root of the crate (replaced by methods). - + +### Removed + * Remove the `Deref` impl for `MatrixVec` as it could cause hard-to-understand compilation errors. + ### nalgebra-glm * Add several alternative projection computations, e.g., `ortho_lh`, `ortho_lh_no`, `perspective_lh`, etc. * Add features matching those of nalgebra, in particular: `serde-serialize`, `abmonation-serialize`, std` (enabled by default). - + ## [0.16.0] All dependencies have been updated to their latest versions. diff --git a/src/base/vec_storage.rs b/src/base/vec_storage.rs index b5005c0c..246c3515 100644 --- a/src/base/vec_storage.rs +++ b/src/base/vec_storage.rs @@ -1,6 +1,5 @@ #[cfg(feature = "abomonation-serialize")] use std::io::{Result as IOResult, Write}; -use std::ops::Deref; #[cfg(all(feature = "alloc", not(feature = "std")))] use alloc::vec::Vec; @@ -81,14 +80,11 @@ impl VecStorage { self.data } -} - -impl Deref for VecStorage { - type Target = Vec; + /// The number of elements on the underlying vector. #[inline] - fn deref(&self) -> &Self::Target { - &self.data + pub fn len(&self) -> usize { + self.data.len() } } @@ -145,7 +141,7 @@ where DefaultAllocator: Allocator #[inline] fn as_slice(&self) -> &[N] { - &self[..] + &self.data } } @@ -189,7 +185,7 @@ where DefaultAllocator: Allocator #[inline] fn as_slice(&self) -> &[N] { - &self[..] + &self.data } }