Skip to content

Commit fe41ca3

Browse files
committed
add ArcArray1 and ArcArray2 aliases
1 parent ad7efff commit fe41ca3

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

serialization-tests/tests/serialize.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ extern crate rmp_serde;
99
#[cfg(feature = "ron")]
1010
extern crate ron;
1111

12-
use ndarray::{arr0, arr1, arr2, s, ArcArray, ArrayD, Ix2, IxDyn};
12+
use ndarray::{arr0, arr1, arr2, s, ArcArray, ArcArray2, ArrayD, IxDyn};
1313

1414
#[test]
1515
fn serial_many_dim_serde() {
@@ -98,13 +98,13 @@ fn serial_ixdyn_serde() {
9898
fn serial_wrong_count_serde() {
9999
// one element too few
100100
let text = r##"{"v":1,"dim":[2,3],"data":[3,1,2.2,3.1,4]}"##;
101-
let arr = serde_json::from_str::<ArcArray<f32, Ix2>>(text);
101+
let arr = serde_json::from_str::<ArcArray2<f32>>(text);
102102
println!("{:?}", arr);
103103
assert!(arr.is_err());
104104

105105
// future version
106106
let text = r##"{"v":200,"dim":[2,3],"data":[3,1,2.2,3.1,4,7]}"##;
107-
let arr = serde_json::from_str::<ArcArray<f32, Ix2>>(text);
107+
let arr = serde_json::from_str::<ArcArray2<f32>>(text);
108108
println!("{:?}", arr);
109109
assert!(arr.is_err());
110110
}

src/aliases.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
44
use crate::dimension::Dim;
55
#[allow(deprecated)]
6-
use crate::{Array, ArrayView, ArrayViewMut, Ix, IxDynImpl, RcArray};
6+
use crate::{ArcArray, Array, ArrayView, ArrayViewMut, Ix, IxDynImpl, RcArray};
77

88
/// Create a zero-dimensional index
99
#[allow(non_snake_case)]
@@ -158,3 +158,8 @@ pub type RcArray1<A> = RcArray<A, Ix1>;
158158
#[allow(deprecated)]
159159
#[deprecated(note = "`RcArray` has been renamed to `ArcArray`")]
160160
pub type RcArray2<A> = RcArray<A, Ix2>;
161+
162+
/// one-dimensional shared ownership array
163+
pub type ArcArray1<A> = ArcArray<A, Ix1>;
164+
/// two-dimensional shared ownership array
165+
pub type ArcArray2<A> = ArcArray<A, Ix2>;

src/free_functions.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
use std::mem::{forget, size_of};
1010
use std::slice;
1111

12-
use crate::dimension;
1312
use crate::imp_prelude::*;
13+
use crate::{dimension, ArcArray1, ArcArray2};
1414

1515
/// Create an [**`Array`**](type.Array.html) with one, two or
1616
/// three dimensions.
@@ -63,7 +63,7 @@ pub fn arr1<A: Clone>(xs: &[A]) -> Array1<A> {
6363
}
6464

6565
/// Create a one-dimensional array with elements from `xs`.
66-
pub fn rcarr1<A: Clone>(xs: &[A]) -> ArcArray<A, Ix1> {
66+
pub fn rcarr1<A: Clone>(xs: &[A]) -> ArcArray1<A> {
6767
arr1(xs).into_shared()
6868
}
6969

@@ -289,7 +289,7 @@ where
289289

290290
/// Create a two-dimensional array with elements from `xs`.
291291
///
292-
pub fn rcarr2<A: Clone, V: Clone + FixedInitializer<Elem = A>>(xs: &[V]) -> ArcArray<A, Ix2> {
292+
pub fn rcarr2<A: Clone, V: Clone + FixedInitializer<Elem = A>>(xs: &[V]) -> ArcArray2<A> {
293293
arr2(xs).into_shared()
294294
}
295295

0 commit comments

Comments
 (0)