Mercurial > hg-stable
changeset 42893:706104dcb2c8
rust-cpython: replace dyn Iterator<..> of sequence with concrete type
We wouldn't care the cost of the dynamic dispatch, but I feel a concrete
type helps understanding error messages.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sun, 08 Sep 2019 12:07:19 +0900 |
parents | 7083ac37314f |
children | 67853749961b |
files | rust/hg-cpython/src/dirstate/dirs_multiset.rs rust/hg-cpython/src/ref_sharing.rs |
diffstat | 2 files changed, 7 insertions(+), 24 deletions(-) [+] |
line wrap: on
line diff
--- a/rust/hg-cpython/src/dirstate/dirs_multiset.rs Sun Sep 08 12:00:26 2019 +0900 +++ b/rust/hg-cpython/src/dirstate/dirs_multiset.rs Sun Sep 08 12:07:19 2019 +0900 @@ -18,7 +18,10 @@ use crate::dirstate::extract_dirstate; use crate::ref_sharing::{PySharedRefCell, PySharedState}; -use hg::{DirsMultiset, DirstateMapError, DirstateParseError, EntryState}; +use hg::{ + DirsMultiset, DirsMultisetIter, DirstateMapError, DirstateParseError, + EntryState, +}; py_class!(pub class Dirs |py| { data inner: PySharedRefCell<DirsMultiset>; @@ -90,7 +93,7 @@ DirsMultisetKeysIterator::create_instance( py, RefCell::new(Some(leak_handle)), - RefCell::new(Box::new(leaked_ref.iter())), + RefCell::new(leaked_ref.iter()), ) } @@ -118,10 +121,10 @@ } } -py_shared_sequence_iterator!( +py_shared_iterator_impl!( DirsMultisetKeysIterator, DirsMultisetLeakedRef, - Vec<u8>, + DirsMultisetIter<'static>, Dirs::translate_key, Option<PyBytes> );
--- a/rust/hg-cpython/src/ref_sharing.rs Sun Sep 08 12:00:26 2019 +0900 +++ b/rust/hg-cpython/src/ref_sharing.rs Sun Sep 08 12:07:19 2019 +0900 @@ -417,23 +417,3 @@ ); }; } - -/// Works basically the same as `py_shared_mapping_iterator`, but with only a -/// key. -macro_rules! py_shared_sequence_iterator { - ( - $name:ident, - $leaked:ident, - $key_type: ty, - $success_func: path, - $success_type: ty - ) => { - py_shared_iterator_impl!( - $name, - $leaked, - Box<dyn Iterator<Item = &'static $key_type> + Send>, - $success_func, - $success_type - ); - }; -}