Skip to content

Commit d8684b7

Browse files
committed
Modified arith operator semantics
1 parent b8b8f0b commit d8684b7

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/array.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ extern {
5757

5858
fn af_eval(arr: AfArray) -> c_int;
5959

60+
fn af_retain_array(out: MutAfArray, arr: AfArray) -> c_int;
61+
6062
fn af_release_array(arr: AfArray) -> c_int;
6163

6264
fn af_print_array(arr: AfArray) -> c_int;
@@ -153,6 +155,16 @@ impl Array {
153155
is_func!(is_bool, af_is_bool);
154156
}
155157

158+
impl Clone for Array {
159+
fn clone(&self) -> Array {
160+
unsafe {
161+
let mut temp: i64 = 0;
162+
af_retain_array(&mut temp as MutAfArray, self.handle as AfArray);
163+
Array {handle: temp}
164+
}
165+
}
166+
}
167+
156168
impl Drop for Array {
157169
fn drop(&mut self) {
158170
unsafe {

tests/hello_world.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ fn main() {
1919
let b: Array = af::sin(&a) + 1.5;
2020
af::print(&b);
2121

22+
let test = a.clone() + b.clone();
23+
af::print(&test);
24+
2225
// printf("Negate the first three elements of second column\n");
2326
// B(seq(0, 2), 1) = B(seq(0, 2), 1) * -1;
2427
// af_print(B);

0 commit comments

Comments
 (0)