Skip to content

Commit

Permalink
Merge pull request #41 from kngwyu/static-type-check
Browse files Browse the repository at this point in the history
Static type checking with PhantomData
  • Loading branch information
kngwyu committed Aug 3, 2018
2 parents 96cb439 + 4e5a8fe commit 5c853af
Show file tree
Hide file tree
Showing 11 changed files with 347 additions and 218 deletions.
3 changes: 2 additions & 1 deletion Cargo.toml
Expand Up @@ -13,4 +13,5 @@ license-file = "LICENSE"
libc = "0.2"
num-complex = "0.1"
ndarray = "0.11"
pyo3 = "0.3.1"
pyo3 = { git = "https://github.com/pyo3/pyo3", rev = "547fa35604a61d2d750390940ed5a0d34ed09821"}

2 changes: 1 addition & 1 deletion example/extensions/Cargo.toml
Expand Up @@ -9,5 +9,5 @@ crate-type = ["cdylib"]

[dependencies]
numpy = { path = "../.." }
pyo3 = { git = "https://github.com/pyo3/pyo3", rev = "547fa35604a61d2d750390940ed5a0d34ed09821"}
ndarray = "0.11"
pyo3 = "0.3.1"
4 changes: 2 additions & 2 deletions example/extensions/src/lib.rs
Expand Up @@ -27,7 +27,7 @@ fn rust_ext(py: Python, m: &PyModule) -> PyResult<()> {

// wrapper of `axpy`
#[pyfn(m, "axpy")]
fn axpy_py(py: Python, a: f64, x: &PyArray, y: &PyArray) -> PyResult<PyArray> {
fn axpy_py(py: Python, a: f64, x: &PyArray<f64>, y: &PyArray<f64>) -> PyResult<PyArray<f64>> {
let np = PyArrayModule::import(py)?;
let x = x.as_array().into_pyresult("x must be f64 array")?;
let y = y.as_array().into_pyresult("y must be f64 array")?;
Expand All @@ -36,7 +36,7 @@ fn rust_ext(py: Python, m: &PyModule) -> PyResult<()> {

// wrapper of `mult`
#[pyfn(m, "mult")]
fn mult_py(_py: Python, a: f64, x: &PyArray) -> PyResult<()> {
fn mult_py(_py: Python, a: f64, x: &PyArray<f64>) -> PyResult<()> {
let x = x.as_array_mut().into_pyresult("x must be f64 array")?;
mult(a, x);
Ok(())
Expand Down
2 changes: 1 addition & 1 deletion example/setup.py
Expand Up @@ -4,7 +4,7 @@
import sys
from setuptools import find_packages, setup
from setuptools.command.test import test as TestCommand
from setuptools_rust import RustExtension, Binding
from setuptools_rust import RustExtension


class CmdTest(TestCommand):
Expand Down

0 comments on commit 5c853af

Please sign in to comment.