Content-Length: 308396 | pFad | http://github.com/psqlpy-python/rust-postgres-array/commit/7a4dd92c1fd0f8187b5b7457b59ca5dddbf1c49e

A1 Merge pull request #7 from jonhoo/add-extract · psqlpy-python/rust-postgres-array@7a4dd92 · GitHub
Skip to content

Commit 7a4dd92

Browse files
committed
Merge pull request sfackler#7 from jonhoo/add-extract
Add .extract() for extracting underlying Vec
2 parents cbb9122 + 4c57ea4 commit 7a4dd92

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/array.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,12 @@ impl<T> Array<T> {
144144
pub fn iter_mut<'a>(&'a mut self) -> IterMut<'a, T> {
145145
IterMut { inner: self.data.iter_mut() }
146146
}
147+
148+
//github.com/ Returns the underlying data vector for this Array in the
149+
//github.com/ higher-dimensional equivalent of row-major order.
150+
pub fn into_inner(self) -> Vec<T> {
151+
self.data
152+
}
147153
}
148154

149155
//github.com/ A trait implemented by types that can index into an `Array`.

src/lib.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,16 @@ mod tests {
4848
assert_eq!(2, a[1]);
4949
}
5050

51+
#[test]
52+
fn test_into_inner() {
53+
let a = Array::from_vec(vec![0i32, 1, 2], -1);
54+
let a = a.into_inner();
55+
assert_eq!(a.len(), 3);
56+
assert_eq!(0, a[0]);
57+
assert_eq!(1, a[1]);
58+
assert_eq!(2, a[2]);
59+
}
60+
5161
#[test]
5262
fn test_2d_slice_get() {
5363
let mut a = Array::from_vec(vec![0i32, 1, 2], -1);

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/psqlpy-python/rust-postgres-array/commit/7a4dd92c1fd0f8187b5b7457b59ca5dddbf1c49e

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy