Show More
@@ -205,6 +205,7 b" impl<'a, T> PySharedRef<'a, T> {" | |||||
205 |
|
205 | |||
206 | /// Holds a mutable reference to data shared between Python and Rust. |
|
206 | /// Holds a mutable reference to data shared between Python and Rust. | |
207 | pub struct PyRefMut<'a, T> { |
|
207 | pub struct PyRefMut<'a, T> { | |
|
208 | py: Python<'a>, | |||
208 | inner: RefMut<'a, T>, |
|
209 | inner: RefMut<'a, T>, | |
209 | py_shared_state: &'a PySharedState, |
|
210 | py_shared_state: &'a PySharedState, | |
210 | } |
|
211 | } | |
@@ -213,11 +214,12 b" impl<'a, T> PyRefMut<'a, T> {" | |||||
213 | // Must be constructed by PySharedState after checking its leak_count. |
|
214 | // Must be constructed by PySharedState after checking its leak_count. | |
214 | // Otherwise, drop() would incorrectly update the state. |
|
215 | // Otherwise, drop() would incorrectly update the state. | |
215 | fn new( |
|
216 | fn new( | |
216 |
|
|
217 | py: Python<'a>, | |
217 | inner: RefMut<'a, T>, |
|
218 | inner: RefMut<'a, T>, | |
218 | py_shared_state: &'a PySharedState, |
|
219 | py_shared_state: &'a PySharedState, | |
219 | ) -> Self { |
|
220 | ) -> Self { | |
220 | Self { |
|
221 | Self { | |
|
222 | py, | |||
221 | inner, |
|
223 | inner, | |
222 | py_shared_state, |
|
224 | py_shared_state, | |
223 | } |
|
225 | } | |
@@ -239,10 +241,8 b" impl<'a, T> std::ops::DerefMut for PyRef" | |||||
239 |
|
241 | |||
240 | impl<'a, T> Drop for PyRefMut<'a, T> { |
|
242 | impl<'a, T> Drop for PyRefMut<'a, T> { | |
241 | fn drop(&mut self) { |
|
243 | fn drop(&mut self) { | |
242 | let gil = Python::acquire_gil(); |
|
|||
243 | let py = gil.python(); |
|
|||
244 | unsafe { |
|
244 | unsafe { | |
245 | self.py_shared_state.decrease_leak_count(py, true); |
|
245 | self.py_shared_state.decrease_leak_count(self.py, true); | |
246 | } |
|
246 | } | |
247 | } |
|
247 | } | |
248 | } |
|
248 | } |
General Comments 0
You need to be logged in to leave comments.
Login now