Add methods to access a DVec<N> as a &[N].

This commit is contained in:
Sébastien Crozet 2013-10-14 15:38:23 +02:00
parent bb5654d220
commit dcd1e7719b
1 changed files with 14 additions and 0 deletions

View File

@ -92,6 +92,20 @@ impl<N> DVec<N> {
*self.at.unsafe_mut_ref(i) = val
}
#[inline]
pub fn as_vec<'r>(&'r self) -> &'r [N] {
let data: &'r [N] = self.at;
data
}
#[inline]
pub fn as_mut_vec<'r>(&'r mut self) -> &'r mut [N] {
let data: &'r mut [N] = self.at;
data
}
#[inline]
pub fn to_vec(self) -> ~[N] {
self.at