Patchwork [2,of,7] rust-dirstate: provide CopyMapIter and StateMapIter types

login
register
mail settings
Submitter Yuya Nishihara
Date Sept. 8, 2019, 10:05 a.m.
Message ID <06763fe8317d686dba58.1567937142@mimosa>
Download mbox | patch
Permalink /patch/41572/
State Accepted
Headers show

Comments

Yuya Nishihara - Sept. 8, 2019, 10:05 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1567911626 -32400
#      Sun Sep 08 12:00:26 2019 +0900
# Node ID 06763fe8317d686dba58464ec4ed74f8325ae825
# Parent  2c5b7c68ea1cc5141d12bd26dd6effe18fe30f44
rust-dirstate: provide CopyMapIter and StateMapIter types

They will be used in the declaration of Python iterator types.

Patch

diff --git a/rust/hg-core/src/dirstate.rs b/rust/hg-core/src/dirstate.rs
--- a/rust/hg-core/src/dirstate.rs
+++ b/rust/hg-core/src/dirstate.rs
@@ -6,6 +6,7 @@ 
 // GNU General Public License version 2 or any later version.
 
 use crate::DirstateParseError;
+use std::collections::hash_map;
 use std::collections::HashMap;
 use std::convert::TryFrom;
 
@@ -31,7 +32,9 @@  pub struct DirstateEntry {
 }
 
 pub type StateMap = HashMap<Vec<u8>, DirstateEntry>;
+pub type StateMapIter<'a> = hash_map::Iter<'a, Vec<u8>, DirstateEntry>;
 pub type CopyMap = HashMap<Vec<u8>, Vec<u8>>;
+pub type CopyMapIter<'a> = hash_map::Iter<'a, Vec<u8>, Vec<u8>>;
 
 #[derive(Copy, Clone, Debug, Eq, PartialEq)]
 pub enum EntryState {
diff --git a/rust/hg-core/src/lib.rs b/rust/hg-core/src/lib.rs
--- a/rust/hg-core/src/lib.rs
+++ b/rust/hg-core/src/lib.rs
@@ -12,7 +12,8 @@  pub use dirstate::{
     dirs_multiset::{DirsMultiset, DirsMultisetIter},
     dirstate_map::DirstateMap,
     parsers::{pack_dirstate, parse_dirstate, PARENT_SIZE},
-    CopyMap, DirstateEntry, DirstateParents, EntryState, StateMap,
+    CopyMap, CopyMapIter, DirstateEntry, DirstateParents, EntryState,
+    StateMap, StateMapIter,
 };
 mod filepatterns;
 pub mod utils;