Skip to content

Commit 54056f7

Browse files
committed
build: Transit package to 2018 edition
1 parent d51b2c0 commit 54056f7

File tree

12 files changed

+81
-86
lines changed

12 files changed

+81
-86
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
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

Lines changed: 2 additions & 1 deletion
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

@@ -63,6 +63,7 @@ numpy = "0.6.0"
6363
``` rust
6464
extern crate numpy;
6565
extern crate pyo3;
66+
6667
use numpy::{PyArray1, get_array_module};
6768
use pyo3::prelude::{ObjectProtocol, PyResult, Python};
6869
use pyo3::types::PyDict;

examples/linalg/src/lib.rs

Lines changed: 3 additions & 2 deletions
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

Lines changed: 2 additions & 1 deletion
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

Lines changed: 6 additions & 9 deletions
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)