Supplement the document of fn as_ptr

This commit is contained in:
Chia-Sheng Chen 2020-04-03 17:56:08 +08:00
parent b996a6f0ce
commit 65bc037b5d
1 changed files with 9 additions and 0 deletions

View File

@ -308,6 +308,15 @@ impl<N: Scalar, R: Dim, C: Dim, S: Storage<N, R, C>> Matrix<N, R, C, S> {
///
/// If the matrix is not empty, this pointer is guaranteed to be aligned
/// and non-null.
///
/// # Example
/// ```
/// # use nalgebra::Matrix2;
/// let m = Matrix2::new(1, 2,
/// 3, 4);
/// let ptr = m.as_ptr();
/// assert_eq!(unsafe { *ptr }, m[0]);
/// ```
#[inline]
pub fn as_ptr(&self) -> *const N {
self.data.ptr()