Content-Length: 294547 | pFad | http://github.com/psqlpy-python/rust-postgres-array/commit/c32f38e06cca8d1eb22127576e997f62e6959d15
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a1a242d commit c32f38eCopy full SHA for c32f38e
src/array.rs
@@ -1,4 +1,5 @@
1
use std::fmt;
2
+use std::io::{Error, ErrorKind};
3
use std::ops::{Index, IndexMut};
4
use std::slice;
5
use std::vec;
@@ -79,6 +80,22 @@ impl<T> Array<T> {
79
80
}
81
82
83
+ pub fn from_parts_with_err(
84
+ data: Vec<T>,
85
+ dimensions: Vec<Dimension>,
86
+ ) -> Result<Array<T>, Error> {
87
+ if (data.is_empty() && dimensions.is_empty())
88
+ || data.len() as i32 == dimensions.iter().fold(1, |acc, i| acc * i.len)
89
+ {
90
+ return Err(Error::new(ErrorKind::Other, "size mismatch"));
91
+ }
92
+
93
+ return Ok(Array {
94
+ dims: dimensions,
95
+ data,
96
+ });
97
98
99
//github.com/ Creates a new one-dimensional array.
100
pub fn from_vec(data: Vec<T>, lower_bound: i32) -> Array<T> {
101
Array {
Fetched URL: http://github.com/psqlpy-python/rust-postgres-array/commit/c32f38e06cca8d1eb22127576e997f62e6959d15
Alternative Proxies:
Alternative Proxy
pFad Proxy
pFad v3 Proxy
pFad v4 Proxy
0 commit comments