@@ -12,7 +12,7 @@ use crate::{
12
12
pyclass:: { create_type_object, PyClassTypeObject } ,
13
13
sync:: { GILOnceCell , GILProtected } ,
14
14
types:: PyType ,
15
- PyClass , PyErr , PyMethodDefType , PyObject , PyResult , Python ,
15
+ Bound , PyClass , PyErr , PyMethodDefType , PyObject , PyResult , Python ,
16
16
} ;
17
17
18
18
use super :: PyClassItemsIter ;
@@ -46,15 +46,15 @@ impl<T> LazyTypeObject<T> {
46
46
47
47
impl < T : PyClass > LazyTypeObject < T > {
48
48
/// Gets the type object contained by this `LazyTypeObject`, initializing it if needed.
49
- pub fn get_or_init < ' py > ( & ' py self , py : Python < ' py > ) -> & ' py PyType {
49
+ pub fn get_or_init < ' py > ( & self , py : Python < ' py > ) -> & Bound < ' py , PyType > {
50
50
self . get_or_try_init ( py) . unwrap_or_else ( |err| {
51
51
err. print ( py) ;
52
52
panic ! ( "failed to create type object for {}" , T :: NAME )
53
53
} )
54
54
}
55
55
56
56
/// Fallible version of the above.
57
- pub ( crate ) fn get_or_try_init < ' py > ( & ' py self , py : Python < ' py > ) -> PyResult < & ' py PyType > {
57
+ pub ( crate ) fn get_or_try_init < ' py > ( & self , py : Python < ' py > ) -> PyResult < & Bound < ' py , PyType > > {
58
58
self . 0
59
59
. get_or_try_init ( py, create_type_object :: < T > , T :: NAME , T :: items_iter ( ) )
60
60
}
@@ -65,18 +65,18 @@ impl LazyTypeObjectInner {
65
65
// so that this code is only instantiated once, instead of for every T
66
66
// like the generic LazyTypeObject<T> methods above.
67
67
fn get_or_try_init < ' py > (
68
- & ' py self ,
68
+ & self ,
69
69
py : Python < ' py > ,
70
70
init : fn ( Python < ' py > ) -> PyResult < PyClassTypeObject > ,
71
71
name : & str ,
72
72
items_iter : PyClassItemsIter ,
73
- ) -> PyResult < & ' py PyType > {
73
+ ) -> PyResult < & Bound < ' py , PyType > > {
74
74
( || -> PyResult < _ > {
75
75
let type_object = self
76
76
. value
77
77
. get_or_try_init ( py, || init ( py) ) ?
78
78
. type_object
79
- . as_ref ( py) ;
79
+ . bind ( py) ;
80
80
self . ensure_init ( type_object, name, items_iter) ?;
81
81
Ok ( type_object)
82
82
} ) ( )
@@ -91,7 +91,7 @@ impl LazyTypeObjectInner {
91
91
92
92
fn ensure_init (
93
93
& self ,
94
- type_object : & PyType ,
94
+ type_object : & Bound < ' _ , PyType > ,
95
95
name : & str ,
96
96
items_iter : PyClassItemsIter ,
97
97
) -> PyResult < ( ) > {
0 commit comments