diff --git a/src/array.rs b/src/array.rs index 996867a..d762932 100644 --- a/src/array.rs +++ b/src/array.rs @@ -144,6 +144,12 @@ impl Array { pub fn iter_mut<'a>(&'a mut self) -> IterMut<'a, T> { IterMut { inner: self.data.iter_mut() } } + + /// Returns the underlying data vector for this Array in the + /// higher-dimensional equivalent of row-major order. + pub fn into_inner(self) -> Vec { + self.data + } } /// A trait implemented by types that can index into an `Array`. diff --git a/src/lib.rs b/src/lib.rs index 026f968..3108e57 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -48,6 +48,16 @@ mod tests { assert_eq!(2, a[1]); } + #[test] + fn test_into_inner() { + let a = Array::from_vec(vec![0i32, 1, 2], -1); + let a = a.into_inner(); + assert_eq!(a.len(), 3); + assert_eq!(0, a[0]); + assert_eq!(1, a[1]); + assert_eq!(2, a[2]); + } + #[test] fn test_2d_slice_get() { let mut a = Array::from_vec(vec![0i32, 1, 2], -1); pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy