Show More
@@ -570,25 +570,14 b' macro_rules! py_shared_iterator {' | |||||
570 | $success_type: ty |
|
570 | $success_type: ty | |
571 | ) => { |
|
571 | ) => { | |
572 | py_class!(pub class $name |py| { |
|
572 | py_class!(pub class $name |py| { | |
573 |
data inner: RefCell< |
|
573 | data inner: RefCell<$leaked>; | |
574 |
|
574 | |||
575 | def __next__(&self) -> PyResult<$success_type> { |
|
575 | def __next__(&self) -> PyResult<$success_type> { | |
576 |
let mut |
|
576 | let mut leaked = self.inner(py).borrow_mut(); | |
577 |
|
|
577 | let mut iter = leaked.try_borrow_mut(py)?; | |
578 | let mut iter = leaked.try_borrow_mut(py)?; |
|
578 | match iter.next() { | |
579 |
|
|
579 | None => Ok(None), | |
580 | None => { |
|
580 | Some(res) => $success_func(py, res), | |
581 | drop(iter); |
|
|||
582 | // replace Some(inner) by None, drop $leaked |
|
|||
583 | inner_opt.take(); |
|
|||
584 | Ok(None) |
|
|||
585 | } |
|
|||
586 | Some(res) => { |
|
|||
587 | $success_func(py, res) |
|
|||
588 | } |
|
|||
589 | } |
|
|||
590 | } else { |
|
|||
591 | Ok(None) |
|
|||
592 | } |
|
581 | } | |
593 | } |
|
582 | } | |
594 |
|
583 | |||
@@ -604,7 +593,7 b' macro_rules! py_shared_iterator {' | |||||
604 | ) -> PyResult<Self> { |
|
593 | ) -> PyResult<Self> { | |
605 | Self::create_instance( |
|
594 | Self::create_instance( | |
606 | py, |
|
595 | py, | |
607 |
RefCell::new( |
|
596 | RefCell::new(leaked), | |
608 | ) |
|
597 | ) | |
609 | } |
|
598 | } | |
610 | } |
|
599 | } |
General Comments 0
You need to be logged in to leave comments.
Login now