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::{
1616#[ pymodule]
1717fn rust_ext < ' py > ( m : & Bound < ' py , PyModule > ) -> PyResult < ( ) > {
1818 // example using generic PyObject
19- fn head ( x : ArrayViewD < ' _ , PyObject > ) -> PyResult < PyObject > {
19+ fn head ( py : Python < ' _ > , x : ArrayViewD < ' _ , PyObject > ) -> PyResult < PyObject > {
2020 x. get ( 0 )
21- . cloned ( )
21+ . map ( |obj| obj . clone_ref ( py ) )
2222 . ok_or_else ( || PyIndexError :: new_err ( "array index out of range" ) )
2323 }
2424
@@ -49,7 +49,7 @@ fn rust_ext<'py>(m: &Bound<'py, PyModule>) -> PyResult<()> {
4949 #[ pyfn( m) ]
5050 #[ pyo3( name = "head" ) ]
5151 fn head_py < ' py > ( x : PyReadonlyArrayDyn < ' py , PyObject > ) -> PyResult < PyObject > {
52- head ( x. as_array ( ) )
52+ head ( x. py ( ) , x . as_array ( ) )
5353 }
5454
5555 // wrapper of `axpy`
You can’t perform that action at this time.
0 commit comments