Skip to content

Commit 3a18675

Browse files
authored
Remove unneeded lifetime annotations (#389)
1 parent 3843fa9 commit 3a18675

File tree

4 files changed

+15
-14
lines changed

4 files changed

+15
-14
lines changed

examples/linalg/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ use numpy::{IntoPyArray, PyArray2, PyReadonlyArray2};
33
use pyo3::{exceptions::PyRuntimeError, pymodule, types::PyModule, PyResult, Python};
44

55
#[pymodule]
6-
fn rust_linalg(_py: Python<'_>, m: &PyModule) -> PyResult<()> {
6+
fn rust_linalg(_py: Python, m: &PyModule) -> PyResult<()> {
77
#[pyfn(m)]
8-
fn inv<'py>(py: Python<'py>, x: PyReadonlyArray2<'py, f64>) -> PyResult<&'py PyArray2<f64>> {
8+
fn inv<'py>(py: Python<'py>, x: PyReadonlyArray2<f64>) -> PyResult<&'py PyArray2<f64>> {
99
let x = x.as_array();
1010
let y = x
1111
.inv()

examples/parallel/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ use numpy::{IntoPyArray, PyArray1, PyReadonlyArray1, PyReadonlyArray2};
66
use pyo3::{pymodule, types::PyModule, PyResult, Python};
77

88
#[pymodule]
9-
fn rust_parallel(_py: Python<'_>, m: &PyModule) -> PyResult<()> {
9+
fn rust_parallel(_py: Python, m: &PyModule) -> PyResult<()> {
1010
#[pyfn(m)]
1111
fn rows_dot<'py>(
1212
py: Python<'py>,
13-
x: PyReadonlyArray2<'py, f64>,
14-
y: PyReadonlyArray1<'py, f64>,
13+
x: PyReadonlyArray2<f64>,
14+
y: PyReadonlyArray1<f64>,
1515
) -> &'py PyArray1<f64> {
1616
let x = x.as_array();
1717
let y = y.as_array();

examples/simple/src/lib.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,26 @@ use pyo3::{
1414
};
1515

1616
#[pymodule]
17-
fn rust_ext(_py: Python<'_>, m: &PyModule) -> PyResult<()> {
17+
fn rust_ext(_py: Python, m: &PyModule) -> PyResult<()> {
1818
// example using generic PyObject
19-
fn head(x: ArrayViewD<'_, PyObject>) -> PyResult<PyObject> {
19+
fn head(x: ArrayViewD<PyObject>) -> PyResult<PyObject> {
2020
x.get(0)
2121
.cloned()
2222
.ok_or_else(|| PyIndexError::new_err("array index out of range"))
2323
}
2424

2525
// example using immutable borrows producing a new array
26-
fn axpy(a: f64, x: ArrayViewD<'_, f64>, y: ArrayViewD<'_, f64>) -> ArrayD<f64> {
26+
fn axpy(a: f64, x: ArrayViewD<f64>, y: ArrayViewD<f64>) -> ArrayD<f64> {
2727
a * &x + &y
2828
}
2929

3030
// example using a mutable borrow to modify an array in-place
31-
fn mult(a: f64, mut x: ArrayViewMutD<'_, f64>) {
31+
fn mult(a: f64, mut x: ArrayViewMutD<f64>) {
3232
x *= a;
3333
}
3434

3535
// example using complex numbers
36-
fn conj(x: ArrayViewD<'_, Complex64>) -> ArrayD<Complex64> {
36+
fn conj(x: ArrayViewD<Complex64>) -> ArrayD<Complex64> {
3737
x.map(|c| c.conj())
3838
}
3939

@@ -45,7 +45,7 @@ fn rust_ext(_py: Python<'_>, m: &PyModule) -> PyResult<()> {
4545
// wrapper of `head`
4646
#[pyfn(m)]
4747
#[pyo3(name = "head")]
48-
fn head_py(_py: Python<'_>, x: PyReadonlyArrayDyn<'_, PyObject>) -> PyResult<PyObject> {
48+
fn head_py(_py: Python, x: PyReadonlyArrayDyn<PyObject>) -> PyResult<PyObject> {
4949
head(x.as_array())
5050
}
5151

@@ -55,8 +55,8 @@ fn rust_ext(_py: Python<'_>, m: &PyModule) -> PyResult<()> {
5555
fn axpy_py<'py>(
5656
py: Python<'py>,
5757
a: f64,
58-
x: PyReadonlyArrayDyn<'_, f64>,
59-
y: PyReadonlyArrayDyn<'_, f64>,
58+
x: PyReadonlyArrayDyn<f64>,
59+
y: PyReadonlyArrayDyn<f64>,
6060
) -> &'py PyArrayDyn<f64> {
6161
let x = x.as_array();
6262
let y = y.as_array();
@@ -77,7 +77,7 @@ fn rust_ext(_py: Python<'_>, m: &PyModule) -> PyResult<()> {
7777
#[pyo3(name = "conj")]
7878
fn conj_py<'py>(
7979
py: Python<'py>,
80-
x: PyReadonlyArrayDyn<'_, Complex64>,
80+
x: PyReadonlyArrayDyn<Complex64>,
8181
) -> &'py PyArrayDyn<Complex64> {
8282
conj(x.as_array()).into_pyarray(py)
8383
}

tests/to_py.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use pyo3::{
1212
#[test]
1313
fn to_pyarray_vec() {
1414
Python::with_gil(|py| {
15+
#[allow(clippy::useless_vec)]
1516
let arr = vec![1, 2, 3].to_pyarray(py);
1617

1718
assert_eq!(arr.shape(), [3]);

0 commit comments

Comments
 (0)