Skip to content

Commit f08d6e0

Browse files
committed
Remove cfg_if dependency, clean up dtype macro
1 parent 61ce229 commit f08d6e0

File tree

2 files changed

+12
-24
lines changed

2 files changed

+12
-24
lines changed

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ keywords = ["python", "numpy", "ffi", "pyo3"]
1515
license = "BSD-2-Clause"
1616

1717
[dependencies]
18-
cfg-if = "1.0"
1918
libc = "0.2"
2019
num-complex = ">= 0.2, <= 0.4"
2120
num-traits = "0.2"

src/dtype.rs

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use std::mem::size_of;
22
use std::os::raw::{c_int, c_long, c_longlong, c_short, c_uint, c_ulong, c_ulonglong, c_ushort};
33

4-
use cfg_if::cfg_if;
54
use num_traits::{Bounded, Zero};
65
use pyo3::{ffi, prelude::*, pyobject_native_type_core, types::PyType, AsPyPointer, PyNativeType};
76

@@ -219,36 +218,26 @@ macro_rules! impl_element_scalar {
219218
}
220219
}
221220
};
222-
($ty:ty, $npy_type:ident $(,#[$meta:meta])*) => {
221+
($ty:ty => $npy_type:ident $(,#[$meta:meta])*) => {
223222
impl_element_scalar!(@impl: $ty, NPY_TYPES::$npy_type $(,#[$meta])*);
224223
};
225-
($ty:ty $(,#[$meta:meta])*) => {
226-
impl_element_scalar!(@impl: $ty, npy_int_type::<$ty>() $(,#[$meta])*);
224+
($($tys:ty),+) => {
225+
$(impl_element_scalar!(@impl: $tys, npy_int_type::<$tys>());)+
227226
};
228227
}
229228

230-
impl_element_scalar!(bool, NPY_BOOL);
231-
impl_element_scalar!(i8);
232-
impl_element_scalar!(i16);
233-
impl_element_scalar!(i32);
234-
impl_element_scalar!(i64);
235-
impl_element_scalar!(u8);
236-
impl_element_scalar!(u16);
237-
impl_element_scalar!(u32);
238-
impl_element_scalar!(u64);
239-
impl_element_scalar!(f32, NPY_FLOAT);
240-
impl_element_scalar!(f64, NPY_DOUBLE);
241-
impl_element_scalar!(Complex32, NPY_CFLOAT,
229+
impl_element_scalar!(bool => NPY_BOOL);
230+
impl_element_scalar!(i8, i16, i32, i64);
231+
impl_element_scalar!(u8, u16, u32, u64);
232+
impl_element_scalar!(f32 => NPY_FLOAT);
233+
impl_element_scalar!(f64 => NPY_DOUBLE);
234+
impl_element_scalar!(Complex32 => NPY_CFLOAT,
242235
#[doc = "Complex type with `f32` components which maps to `np.csingle` (`np.complex64`)."]);
243-
impl_element_scalar!(Complex64, NPY_CDOUBLE,
236+
impl_element_scalar!(Complex64 => NPY_CDOUBLE,
244237
#[doc = "Complex type with `f64` components which maps to `np.cdouble` (`np.complex128`)."]);
245238

246-
cfg_if! {
247-
if #[cfg(any(target_pointer_width = "32", target_pointer_width = "64"))] {
248-
impl_element_scalar!(usize);
249-
impl_element_scalar!(isize);
250-
}
251-
}
239+
#[cfg(any(target_pointer_width = "32", target_pointer_width = "64"))]
240+
impl_element_scalar!(usize, isize);
252241

253242
unsafe impl Element for PyObject {
254243
const IS_COPY: bool = false;

0 commit comments

Comments
 (0)