File tree Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Original file line number Diff line number Diff line change @@ -16,9 +16,9 @@ use pyo3::{
16
16
#[ pymodule]
17
17
fn rust_ext < ' py > ( m : & Bound < ' py , PyModule > ) -> PyResult < ( ) > {
18
18
// example using generic PyObject
19
- fn head ( x : ArrayViewD < ' _ , PyObject > ) -> PyResult < PyObject > {
19
+ fn head ( py : Python < ' _ > , x : ArrayViewD < ' _ , PyObject > ) -> PyResult < PyObject > {
20
20
x. get ( 0 )
21
- . cloned ( )
21
+ . map ( |obj| obj . clone_ref ( py ) )
22
22
. ok_or_else ( || PyIndexError :: new_err ( "array index out of range" ) )
23
23
}
24
24
@@ -49,7 +49,7 @@ fn rust_ext<'py>(m: &Bound<'py, PyModule>) -> PyResult<()> {
49
49
#[ pyfn( m) ]
50
50
#[ pyo3( name = "head" ) ]
51
51
fn head_py < ' py > ( x : PyReadonlyArrayDyn < ' py , PyObject > ) -> PyResult < PyObject > {
52
- head ( x. as_array ( ) )
52
+ head ( x. py ( ) , x . as_array ( ) )
53
53
}
54
54
55
55
// wrapper of `axpy`
You can’t perform that action at this time.
0 commit comments