Skip to content

Commit ab618ad

Browse files
committed
Made our own One+Zero traits so we can use stable rust
1 parent 80651c9 commit ab618ad

File tree

3 files changed

+36
-3
lines changed

3 files changed

+36
-3
lines changed

src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![feature(zero_one)]
2-
31
#![doc(html_logo_url = "http://www.arrayfire.com/logos/arrayfire_logo_symbol.png",
42
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
53
html_root_url = "http://arrayfire.com/docs/rust")]
@@ -73,6 +71,7 @@ mod image;
7371
pub use lapack::{svd, lu, qr, cholesky, solve, solve_lu, inverse, det, rank, norm};
7472
pub use lapack::{svd_inplace, lu_inplace, qr_inplace, cholesky_inplace};
7573
mod lapack;
74+
mod num;
7675

7776
pub use signal::{approx1, approx2};
7877
pub use signal::{fft, fft2, fft3, ifft, ifft2, ifft3};

src/num.rs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
pub trait Zero {
2+
fn zero() -> Self;
3+
}
4+
5+
pub trait One {
6+
fn one() -> Self;
7+
}
8+
9+
impl Zero for u8 { fn zero() -> Self { 0 } }
10+
impl Zero for u16 { fn zero() -> Self { 0 } }
11+
impl Zero for u32 { fn zero() -> Self { 0 } }
12+
impl Zero for u64 { fn zero() -> Self { 0 } }
13+
impl Zero for usize { fn zero() -> Self { 0 } }
14+
impl Zero for i8 { fn zero() -> Self { 0 } }
15+
impl Zero for i16 { fn zero() -> Self { 0 } }
16+
impl Zero for i32 { fn zero() -> Self { 0 } }
17+
impl Zero for i64 { fn zero() -> Self { 0 } }
18+
impl Zero for isize { fn zero() -> Self { 0 } }
19+
impl Zero for f32 { fn zero() -> Self { 0.0 } }
20+
impl Zero for f64 { fn zero() -> Self { 0.0 } }
21+
22+
impl One for u8 { fn one() -> Self { 1 } }
23+
impl One for u16 { fn one() -> Self { 1 } }
24+
impl One for u32 { fn one() -> Self { 1 } }
25+
impl One for u64 { fn one() -> Self { 1 } }
26+
impl One for usize { fn one() -> Self { 1 } }
27+
impl One for i8 { fn one() -> Self { 1 } }
28+
impl One for i16 { fn one() -> Self { 1 } }
29+
impl One for i32 { fn one() -> Self { 1 } }
30+
impl One for i64 { fn one() -> Self { 1 } }
31+
impl One for isize { fn one() -> Self { 1 } }
32+
impl One for f32 { fn one() -> Self { 1.0 } }
33+
impl One for f64 { fn one() -> Self { 1.0 } }

src/seq.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ extern crate libc;
22

33
use std::fmt;
44
use std::default::Default;
5-
use std::num::{One, Zero};
5+
6+
use num::{One, Zero};
67

78
/// Sequences are used for indexing Arrays
89
#[derive(Copy, Clone)]

0 commit comments

Comments
 (0)