diff --git a/lib/src/local_working_copy.rs b/lib/src/local_working_copy.rs index db181e7f2..5783433fc 100644 --- a/lib/src/local_working_copy.rs +++ b/lib/src/local_working_copy.rs @@ -206,6 +206,20 @@ fn file_states_from_proto( .collect() } +fn file_states_to_proto( + file_states: &BTreeMap, +) -> Vec { + file_states + .iter() + .map( + |(path, state)| crate::protos::working_copy::FileStateEntry { + path: path.to_internal_file_string(), + state: Some(file_state_to_proto(state)), + }, + ) + .collect() +} + fn sparse_patterns_from_proto( proto: Option<&crate::protos::working_copy::SparsePatterns>, ) -> Vec { @@ -466,16 +480,7 @@ impl TreeState { } } - proto.file_states = self - .file_states - .iter() - .map( - |(path, state)| crate::protos::working_copy::FileStateEntry { - path: path.to_internal_file_string(), - state: Some(file_state_to_proto(state)), - }, - ) - .collect(); + proto.file_states = file_states_to_proto(&self.file_states); let mut sparse_patterns = crate::protos::working_copy::SparsePatterns::default(); for path in &self.sparse_patterns { sparse_patterns