changeset 49983:795b5b01cbd2

rhg-files: make signature of `display_files` more flexible This allows the callers to use any error type that converts to `CommandError` instead of a particular concrete type.
author Raphaël Gomès <rgomes@octobus.net>
date Wed, 11 Jan 2023 17:28:48 +0100
parents 7faedeb24eb2
children df9eabc9837b
files rust/rhg/src/commands/files.rs
diffstat 1 files changed, 6 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/rust/rhg/src/commands/files.rs	Thu Jan 12 10:28:56 2023 +0100
+++ b/rust/rhg/src/commands/files.rs	Wed Jan 11 17:28:48 2023 +0100
@@ -2,7 +2,6 @@
 use crate::ui::Ui;
 use crate::utils::path_utils::RelativizePaths;
 use clap::Arg;
-use hg::errors::HgError;
 use hg::operations::list_rev_tracked_files;
 use hg::repo::Repo;
 use hg::utils::filter_map_results;
@@ -85,11 +84,14 @@
     }
 }
 
-fn display_files<'a>(
+fn display_files<'a, E>(
     ui: &Ui,
     repo: &Repo,
-    files: impl IntoIterator<Item = Result<&'a HgPath, HgError>>,
-) -> Result<(), CommandError> {
+    files: impl IntoIterator<Item = Result<&'a HgPath, E>>,
+) -> Result<(), CommandError>
+where
+    CommandError: From<E>,
+{
     let mut stdout = ui.stdout_buffer();
     let mut any = false;