From 8268af9b4f38b4da88b9a1bc40921dae4ea2431f Mon Sep 17 00:00:00 2001 From: Yuya Nishihara Date: Sun, 11 Aug 2024 22:01:17 +0900 Subject: [PATCH] merge: add helper function to match Option> More callers will be added by the next commit. --- lib/src/merge.rs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/lib/src/merge.rs b/lib/src/merge.rs index 8d27ec92f..912000356 100644 --- a/lib/src/merge.rs +++ b/lib/src/merge.rs @@ -617,15 +617,10 @@ where store: &Arc, dir: &RepoPath, ) -> BackendResult>> { - let tree_id_merge = self.maybe_map(|term| match term { + let tree_id_merge = self.maybe_map(|term| match borrow_tree_value(term.as_ref()) { None => Some(None), - Some(value) => { - if let TreeValue::Tree(id) = value.borrow() { - Some(Some(id)) - } else { - None - } - } + Some(TreeValue::Tree(id)) => Some(Some(id)), + Some(_) => None, }); if let Some(tree_id_merge) = tree_id_merge { let get_tree = |id: &Option<&TreeId>| -> BackendResult { @@ -642,6 +637,10 @@ where } } +fn borrow_tree_value + ?Sized>(term: Option<&T>) -> Option<&TreeValue> { + term.map(|value| value.borrow()) +} + fn describe_conflict_term(value: &TreeValue) -> String { match value { TreeValue::File {