rust-dirstate: specify concrete return type of DirsMultiset::iter()
This allows us to put a returned iterator in a struct. We could implement
DirsMultisetIter(hash_map::Keys<..>) struct to hide the implementation
detail, but I think type alias is good enough for us.
--- a/rust/hg-core/src/dirstate/dirs_multiset.rs Sat Apr 27 02:04:05 2019 +0200
+++ b/rust/hg-core/src/dirstate/dirs_multiset.rs Sun Sep 08 11:55:29 2019 +0900
@@ -11,9 +11,12 @@
use crate::{
dirstate::EntryState, utils::files, DirstateEntry, DirstateMapError,
};
-use std::collections::hash_map::Entry;
+use std::collections::hash_map::{self, Entry};
use std::collections::HashMap;
+// could be encapsulated if we care API stability more seriously
+pub type DirsMultisetIter<'a> = hash_map::Keys<'a, Vec<u8>, u32>;
+
#[derive(PartialEq, Debug)]
pub struct DirsMultiset {
inner: HashMap<Vec<u8>, u32>,
@@ -105,7 +108,7 @@
self.inner.contains_key(key)
}
- pub fn iter(&self) -> impl Iterator<Item = &Vec<u8>> {
+ pub fn iter(&self) -> DirsMultisetIter {
self.inner.keys()
}
--- a/rust/hg-core/src/lib.rs Sat Apr 27 02:04:05 2019 +0200
+++ b/rust/hg-core/src/lib.rs Sun Sep 08 11:55:29 2019 +0900
@@ -9,7 +9,7 @@
pub mod discovery;
pub mod testing; // unconditionally built, for use from integration tests
pub use dirstate::{
- dirs_multiset::DirsMultiset,
+ dirs_multiset::{DirsMultiset, DirsMultisetIter},
dirstate_map::DirstateMap,
parsers::{pack_dirstate, parse_dirstate, PARENT_SIZE},
CopyMap, DirstateEntry, DirstateParents, EntryState, StateMap,