From b738f884c4be293d127b16846290d3d873e740f0 Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Thu, 6 Jul 2023 05:18:09 -0700 Subject: [PATCH] tree: drop `Diff::as_options()`, use `Diff::into_options()` instead We don't have any current callers that only have a reference to a `Diff`, so we don't need `.as_options()`. --- lib/src/tree.rs | 8 -------- src/diff_util.rs | 6 +++--- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/lib/src/tree.rs b/lib/src/tree.rs index 60ba9c8c1..08ed2dc42 100644 --- a/lib/src/tree.rs +++ b/lib/src/tree.rs @@ -302,14 +302,6 @@ pub enum Diff { } impl Diff { - pub fn as_options(&self) -> (Option<&T>, Option<&T>) { - match self { - Diff::Modified(left, right) => (Some(left), Some(right)), - Diff::Added(right) => (None, Some(right)), - Diff::Removed(left) => (Some(left), None), - } - } - pub fn into_options(self) -> (Option, Option) { match self { Diff::Modified(left, right) => (Some(left), Some(right)), diff --git a/src/diff_util.rs b/src/diff_util.rs index 68f77f638..347aabba3 100644 --- a/src/diff_util.rs +++ b/src/diff_util.rs @@ -713,12 +713,12 @@ pub fn show_types( ) -> io::Result<()> { formatter.with_label("diff", |formatter| { for (repo_path, diff) in tree_diff { - let (before, after) = diff.as_options(); + let (before, after) = diff.into_options(); writeln!( formatter.labeled("modified"), "{}{} {}", - diff_summary_char(before), - diff_summary_char(after), + diff_summary_char(before.as_ref()), + diff_summary_char(after.as_ref()), workspace_command.format_file_path(&repo_path) )?; }