diff --git a/src/cli_util.rs b/src/cli_util.rs index ade7326f3..5b6f46308 100644 --- a/src/cli_util.rs +++ b/src/cli_util.rs @@ -58,7 +58,6 @@ use tracing_subscriber::prelude::*; use crate::config::{FullCommandArgs, LayeredConfigs}; use crate::formatter::{Formatter, PlainTextFormatter}; use crate::merge_tools::{ConflictResolveError, DiffEditError}; -use crate::templater::TemplateFormatter; use crate::ui::{ColorChoice, Ui}; #[derive(Clone, Debug)] @@ -1389,9 +1388,7 @@ pub fn write_commit_summary( .unwrap_or_else(|_| String::from(r#"commit_id.short() " " description.first_line()"#)); let template = crate::template_parser::parse_commit_template(repo, workspace_id, &template_string); - let mut template_writer = TemplateFormatter::new(template, formatter); - template_writer.format(commit)?; - Ok(()) + template.format(commit, formatter) } pub fn write_config_entry( diff --git a/src/templater.rs b/src/templater.rs index d6e691439..5c1e278cb 100644 --- a/src/templater.rs +++ b/src/templater.rs @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -use std::borrow::BorrowMut; use std::collections::{HashMap, HashSet}; use std::io; use std::ops::AddAssign; @@ -31,25 +30,6 @@ pub trait Template { fn format(&self, context: &C, formatter: &mut dyn Formatter) -> io::Result<()>; } -// TODO: Extract a trait for this type? -pub struct TemplateFormatter<'f, 't: 'f, C> { - template: Box + 't>, - formatter: &'f mut dyn Formatter, -} - -impl<'f, 't: 'f, C> TemplateFormatter<'f, 't, C> { - pub fn new(template: Box + 't>, formatter: &'f mut dyn Formatter) -> Self { - TemplateFormatter { - template, - formatter, - } - } - - pub fn format<'c, 'a: 'c>(&'a mut self, context: &'c C) -> io::Result<()> { - self.template.format(context, self.formatter.borrow_mut()) - } -} - pub struct LiteralTemplate(pub String); impl Template for LiteralTemplate {