Rename VecStorage::data/data_mut to ::as_vec/as_vec_mut

This commit is contained in:
sebcrozet 2019-02-03 11:47:23 +01:00
parent 664658760a
commit f52bd4be3d
2 changed files with 5 additions and 4 deletions

View File

@ -270,7 +270,7 @@ where DefaultAllocator: Allocator<N, R, C>
/// let vec_ptr = vec.as_ptr(); /// let vec_ptr = vec.as_ptr();
/// ///
/// let matrix = Matrix::from_vec_generic(Dynamic::new(vec.len()), U1, vec); /// let matrix = Matrix::from_vec_generic(Dynamic::new(vec.len()), U1, vec);
/// let matrix_storage_ptr = matrix.data.as_ptr(); /// let matrix_storage_ptr = matrix.data.as_vec().as_ptr();
/// ///
/// // `matrix` is backed by exactly the same `Vec` as it was constructed from. /// // `matrix` is backed by exactly the same `Vec` as it was constructed from.
/// assert_eq!(matrix_storage_ptr, vec_ptr); /// assert_eq!(matrix_storage_ptr, vec_ptr);

View File

@ -50,15 +50,16 @@ impl<N, R: Dim, C: Dim> VecStorage<N, R, C> {
/// The underlying data storage. /// The underlying data storage.
#[inline] #[inline]
pub fn data(&self) -> &Vec<N> { pub fn as_vec(&self) -> &Vec<N> {
&self.data &self.data
} }
/// The underlying mutable data storage. /// The underlying mutable data storage.
/// ///
/// This is unsafe because this may cause UB if the vector is modified by the user. /// This is unsafe because this may cause UB if the size of the vector is changed
/// by the user.
#[inline] #[inline]
pub unsafe fn data_mut(&mut self) -> &mut Vec<N> { pub unsafe fn as_vec_mut(&mut self) -> &mut Vec<N> {
&mut self.data &mut self.data
} }