Show More
@@ -283,7 +283,7 b' macro_rules! py_shared_ref {' | |||||
283 | /// borrowed. |
|
283 | /// borrowed. | |
284 | pub struct PyLeaked<T> { |
|
284 | pub struct PyLeaked<T> { | |
285 | inner: PyObject, |
|
285 | inner: PyObject, | |
286 |
data: |
|
286 | data: T, | |
287 | py_shared_state: &'static PySharedState, |
|
287 | py_shared_state: &'static PySharedState, | |
288 | /// Generation counter of data `T` captured when PyLeaked is created. |
|
288 | /// Generation counter of data `T` captured when PyLeaked is created. | |
289 | generation: usize, |
|
289 | generation: usize, | |
@@ -305,7 +305,7 b' impl<T> PyLeaked<T> {' | |||||
305 | ) -> Self { |
|
305 | ) -> Self { | |
306 | Self { |
|
306 | Self { | |
307 | inner: inner.clone_ref(py), |
|
307 | inner: inner.clone_ref(py), | |
308 |
data: |
|
308 | data: data, | |
309 | py_shared_state, |
|
309 | py_shared_state, | |
310 | generation: py_shared_state.current_generation(py), |
|
310 | generation: py_shared_state.current_generation(py), | |
311 | } |
|
311 | } | |
@@ -321,7 +321,7 b' impl<T> PyLeaked<T> {' | |||||
321 | self.validate_generation(py)?; |
|
321 | self.validate_generation(py)?; | |
322 | Ok(PyLeakedRef { |
|
322 | Ok(PyLeakedRef { | |
323 | _borrow: BorrowPyShared::new(py, self.py_shared_state), |
|
323 | _borrow: BorrowPyShared::new(py, self.py_shared_state), | |
324 |
data: self.data |
|
324 | data: &self.data, | |
325 | }) |
|
325 | }) | |
326 | } |
|
326 | } | |
327 |
|
327 | |||
@@ -338,7 +338,7 b' impl<T> PyLeaked<T> {' | |||||
338 | self.validate_generation(py)?; |
|
338 | self.validate_generation(py)?; | |
339 | Ok(PyLeakedRefMut { |
|
339 | Ok(PyLeakedRefMut { | |
340 | _borrow: BorrowPyShared::new(py, self.py_shared_state), |
|
340 | _borrow: BorrowPyShared::new(py, self.py_shared_state), | |
341 |
data: self.data |
|
341 | data: &mut self.data, | |
342 | }) |
|
342 | }) | |
343 | } |
|
343 | } | |
344 |
|
344 | |||
@@ -361,7 +361,7 b' impl<T> PyLeaked<T> {' | |||||
361 | /// corresponding `PyLeaked` is alive. Do not copy it out of the |
|
361 | /// corresponding `PyLeaked` is alive. Do not copy it out of the | |
362 | /// function call. |
|
362 | /// function call. | |
363 | pub unsafe fn map<U>( |
|
363 | pub unsafe fn map<U>( | |
364 |
|
|
364 | self, | |
365 | py: Python, |
|
365 | py: Python, | |
366 | f: impl FnOnce(T) -> U, |
|
366 | f: impl FnOnce(T) -> U, | |
367 | ) -> PyLeaked<U> { |
|
367 | ) -> PyLeaked<U> { | |
@@ -374,10 +374,10 b' impl<T> PyLeaked<T> {' | |||||
374 | // In order to make this function safe, maybe we'll need a way to |
|
374 | // In order to make this function safe, maybe we'll need a way to | |
375 | // temporarily restrict the lifetime of self.data and translate the |
|
375 | // temporarily restrict the lifetime of self.data and translate the | |
376 | // returned object back to Something<'static>. |
|
376 | // returned object back to Something<'static>. | |
377 |
let new_data = f(self.data |
|
377 | let new_data = f(self.data); | |
378 | PyLeaked { |
|
378 | PyLeaked { | |
379 |
inner: self.inner |
|
379 | inner: self.inner, | |
380 |
data: |
|
380 | data: new_data, | |
381 | py_shared_state: self.py_shared_state, |
|
381 | py_shared_state: self.py_shared_state, | |
382 | generation: self.generation, |
|
382 | generation: self.generation, | |
383 | } |
|
383 | } |
General Comments 0
You need to be logged in to leave comments.
Login now