Skip to content

Commit

Permalink
Merge pull request #480 from jturner314/as_ptr
Browse files Browse the repository at this point in the history
Add as_ptr and as_mut_ptr methods
  • Loading branch information
sebcrozet committed Feb 3, 2019
2 parents 8117f61 + cc7bab9 commit 24e6ce6
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/base/matrix.rs
Expand Up @@ -295,6 +295,15 @@ impl<N: Scalar, R: Dim, C: Dim, S: Storage<N, R, C>> Matrix<N, R, C, S> {
}
}

/// Returns a pointer to the start of the matrix.
///
/// If the matrix is not empty, this pointer is guaranteed to be aligned
/// and non-null.
#[inline]
pub fn as_ptr(&self) -> *const N {
self.data.ptr()
}

/// Tests whether `self` and `rhs` are equal up to a given epsilon.
///
/// See `relative_eq` from the `RelativeEq` trait for more details.
Expand Down Expand Up @@ -622,6 +631,15 @@ impl<N: Scalar, R: Dim, C: Dim, S: StorageMut<N, R, C>> Matrix<N, R, C, S> {
MatrixIterMut::new(&mut self.data)
}

/// Returns a mutable pointer to the start of the matrix.
///
/// If the matrix is not empty, this pointer is guaranteed to be aligned
/// and non-null.
#[inline]
pub fn as_mut_ptr(&mut self) -> *mut N {
self.data.ptr_mut()
}

/// Mutably iterates through this matrix rows.
///
/// # Example
Expand Down

0 comments on commit 24e6ce6

Please sign in to comment.