Skip to content

Commit b770a38

Browse files
authored
Merge pull request #109 from lzutao/edition
build: Transit package to 2018 edition
2 parents d51b2c0 + 10e0944 commit b770a38

File tree

14 files changed

+98
-95
lines changed

14 files changed

+98
-95
lines changed

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ version = "0.6.0"
44
authors = ["Toshiki Teramura <[email protected]>", "Yuji Kanagawa <[email protected]>"]
55
description = "Rust binding of NumPy C-API"
66
documentation = "https://rust-numpy.github.io/rust-numpy/numpy"
7+
edition = "2018"
78
repository = "https://github.com/rust-numpy/rust-numpy"
89
keywords = ["numpy", "python", "binding"]
910
license-file = "LICENSE"

README.md

+2-8
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ features = ["python2"]
4242
```
4343
.
4444

45-
You can also automatically specify python version in [setup.py](examples/simple-extension/setup.py),
45+
You can also automatically specify python version in [setup.py](examples/simple-extension/setup.py),
4646
using [setuptools-rust](https://github.com/PyO3/setuptools-rust).
4747

4848

@@ -60,9 +60,7 @@ pyo3 = "0.7"
6060
numpy = "0.6.0"
6161
```
6262

63-
``` rust
64-
extern crate numpy;
65-
extern crate pyo3;
63+
```rust
6664
use numpy::{PyArray1, get_array_module};
6765
use pyo3::prelude::{ObjectProtocol, PyResult, Python};
6866
use pyo3::types::PyDict;
@@ -109,10 +107,6 @@ features = ["extension-module"]
109107
```
110108

111109
```rust
112-
extern crate ndarray;
113-
extern crate numpy;
114-
extern crate pyo3;
115-
116110
use ndarray::{ArrayD, ArrayViewD, ArrayViewMutD};
117111
use numpy::{IntoPyArray, PyArrayDyn};
118112
use pyo3::prelude::{pymodule, Py, PyModule, PyResult, Python};

appveyor.yml

-1
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,4 @@ build_script:
2323

2424
test_script:
2525
- cargo test --verbose --features %FEATURES% -- --test-threads=1
26-
- rustdoc --test README.md -L native="%PYTHON%\\libs" -L target/debug/deps/
2726
- cd examples/simple-extension && python setup.py install && python setup.py test

ci/travis/test.sh

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ set -ex
44

55
cargo build --verbose --features $FEATURES
66
cargo test --verbose --features $FEATURES -- --test-threads=1
7-
rustdoc -L target/debug/deps/ --test README.md
87

98
for example in examples/*; do
109
if [ $example != 'examples/linalg' ]; then

examples/linalg/src/lib.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![deny(rust_2018_idioms)]
12
use ndarray_linalg::solve::Inverse;
23
use numpy::{IntoPyArray, PyArray2};
34
use pyo3::exceptions::RuntimeError;
@@ -9,9 +10,9 @@ fn make_error<E: Display + Sized>(e: E) -> PyErr {
910
}
1011

1112
#[pymodule]
12-
fn rust_linalg(_py: Python, m: &PyModule) -> PyResult<()> {
13+
fn rust_linalg(_py: Python<'_>, m: &PyModule) -> PyResult<()> {
1314
#[pyfn(m, "inv")]
14-
fn inv(py: Python, x: &PyArray2<f64>) -> PyResult<Py<PyArray2<f64>>> {
15+
fn inv(py: Python<'_>, x: &PyArray2<f64>) -> PyResult<Py<PyArray2<f64>>> {
1516
let x = x.as_array().inv().map_err(make_error)?;
1617
Ok(x.into_pyarray(py).to_owned())
1718
}

examples/simple-extension/Cargo.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
name = "numpy-example"
33
version = "0.1.0"
44
authors = ["Toshiki Teramura <[email protected]>"]
5+
edition = "2018"
56

67
[lib]
78
name = "rust_ext"
@@ -13,4 +14,4 @@ ndarray = "0.12"
1314

1415
[dependencies.pyo3]
1516
version = "0.7"
16-
features = ["extension-module"]
17+
features = ["extension-module"]

examples/simple-extension/src/lib.rs

+6-9
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,24 @@
1-
extern crate ndarray;
2-
extern crate numpy;
3-
extern crate pyo3;
4-
1+
#![deny(rust_2018_idioms)]
52
use ndarray::{ArrayD, ArrayViewD, ArrayViewMutD};
63
use numpy::{IntoPyArray, PyArrayDyn};
74
use pyo3::prelude::{pymodule, Py, PyModule, PyResult, Python};
85

96
#[pymodule]
10-
fn rust_ext(_py: Python, m: &PyModule) -> PyResult<()> {
7+
fn rust_ext(_py: Python<'_>, m: &PyModule) -> PyResult<()> {
118
// immutable example
12-
fn axpy(a: f64, x: ArrayViewD<f64>, y: ArrayViewD<f64>) -> ArrayD<f64> {
9+
fn axpy(a: f64, x: ArrayViewD<'_, f64>, y: ArrayViewD<'_, f64>) -> ArrayD<f64> {
1310
a * &x + &y
1411
}
1512

1613
// mutable example (no return)
17-
fn mult(a: f64, mut x: ArrayViewMutD<f64>) {
14+
fn mult(a: f64, mut x: ArrayViewMutD<'_, f64>) {
1815
x *= a;
1916
}
2017

2118
// wrapper of `axpy`
2219
#[pyfn(m, "axpy")]
2320
fn axpy_py(
24-
py: Python,
21+
py: Python<'_>,
2522
a: f64,
2623
x: &PyArrayDyn<f64>,
2724
y: &PyArrayDyn<f64>,
@@ -33,7 +30,7 @@ fn rust_ext(_py: Python, m: &PyModule) -> PyResult<()> {
3330

3431
// wrapper of `mult`
3532
#[pyfn(m, "mult")]
36-
fn mult_py(_py: Python, a: f64, x: &PyArrayDyn<f64>) -> PyResult<()> {
33+
fn mult_py(_py: Python<'_>, a: f64, x: &PyArrayDyn<f64>) -> PyResult<()> {
3734
let x = x.as_array_mut();
3835
mult(a, x);
3936
Ok(())

0 commit comments

Comments
 (0)