# HG changeset patch # User Raphaël Gomès # Date 2023-01-11 16:28:48 # Node ID 795b5b01cbd276639921a14d00421372705ad991 # Parent 7faedeb24eb232a804945e43cdb13f1666f36e11 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. diff --git a/rust/rhg/src/commands/files.rs b/rust/rhg/src/commands/files.rs --- a/rust/rhg/src/commands/files.rs +++ b/rust/rhg/src/commands/files.rs @@ -2,7 +2,6 @@ use crate::error::CommandError; 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 @@ pub fn run(invocation: &crate::CliInvoca } } -fn display_files<'a>( +fn display_files<'a, E>( ui: &Ui, repo: &Repo, - files: impl IntoIterator>, -) -> Result<(), CommandError> { + files: impl IntoIterator>, +) -> Result<(), CommandError> +where + CommandError: From, +{ let mut stdout = ui.stdout_buffer(); let mut any = false;