Skip to content

Commit 2e1b069

Browse files
committed
Use pyobject_native_type macro exposed in PyO3/pyo3#155
1 parent 1958ae1 commit 2e1b069

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

Cargo.toml

+5-1
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,8 @@ license-file = "LICENSE"
1313
libc = "0.2"
1414
num-complex = "0.1"
1515
ndarray = "0.10"
16-
pyo3 = "0.2"
16+
17+
[dependencies.pyo3]
18+
git = "http://github.com/termoshtt/pyo3"
19+
branch = "pyobject_macros"
20+
version = "0.2"

src/array.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,7 @@ use super::*;
1414
/// Untyped safe interface for NumPy ndarray.
1515
pub struct PyArray(PyObject);
1616

17-
impl ToPyPointer for PyArray {
18-
fn as_ptr(&self) -> *mut ffi::PyObject {
19-
self.0.as_ptr()
20-
}
21-
}
17+
pyobject_native_type!(PyArray, npyffi::PyArray_Type, npyffi::PyArray_Check);
2218

2319
impl PyArray {
2420
pub fn as_array_ptr(&self) -> *mut npyffi::PyArrayObject {

src/lib.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
#![feature(specialization)]
2+
13
extern crate libc;
24
extern crate ndarray;
35
extern crate num_complex;
6+
#[macro_use]
47
extern crate pyo3;
58

69
pub mod array;

0 commit comments

Comments
 (0)