diff --git a/src/template_parser.rs b/src/template_parser.rs index 271a4fd8c..462ad2312 100644 --- a/src/template_parser.rs +++ b/src/template_parser.rs @@ -103,6 +103,41 @@ impl TemplateProperty for RelativeTimestampString { } } +enum Property<'a, I> { + String(Box + 'a>), + Boolean(Box + 'a>), + CommitId(Box + 'a>), + Signature(Box + 'a>), + Timestamp(Box + 'a>), +} + +impl<'a, I: 'a> Property<'a, I> { + fn after(self, first: Box + 'a>) -> Property<'a, C> { + match self { + Property::String(property) => Property::String(Box::new(TemplateFunction::new( + first, + Box::new(move |value| property.extract(&value)), + ))), + Property::Boolean(property) => Property::Boolean(Box::new(TemplateFunction::new( + first, + Box::new(move |value| property.extract(&value)), + ))), + Property::CommitId(property) => Property::CommitId(Box::new(TemplateFunction::new( + first, + Box::new(move |value| property.extract(&value)), + ))), + Property::Signature(property) => Property::Signature(Box::new(TemplateFunction::new( + first, + Box::new(move |value| property.extract(&value)), + ))), + Property::Timestamp(property) => Property::Timestamp(Box::new(TemplateFunction::new( + first, + Box::new(move |value| property.extract(&value)), + ))), + } + } +} + fn parse_method_chain<'a, I: 'a>( pair: Pair, input_property: Property<'a, I>, @@ -216,41 +251,6 @@ fn parse_timestamp_method<'a>(method: Pair) -> PropertyAndLabels<'a, Times parse_method_chain(chain_method, this_function) } -enum Property<'a, I> { - String(Box + 'a>), - Boolean(Box + 'a>), - CommitId(Box + 'a>), - Signature(Box + 'a>), - Timestamp(Box + 'a>), -} - -impl<'a, I: 'a> Property<'a, I> { - fn after(self, first: Box + 'a>) -> Property<'a, C> { - match self { - Property::String(property) => Property::String(Box::new(TemplateFunction::new( - first, - Box::new(move |value| property.extract(&value)), - ))), - Property::Boolean(property) => Property::Boolean(Box::new(TemplateFunction::new( - first, - Box::new(move |value| property.extract(&value)), - ))), - Property::CommitId(property) => Property::CommitId(Box::new(TemplateFunction::new( - first, - Box::new(move |value| property.extract(&value)), - ))), - Property::Signature(property) => Property::Signature(Box::new(TemplateFunction::new( - first, - Box::new(move |value| property.extract(&value)), - ))), - Property::Timestamp(property) => Property::Timestamp(Box::new(TemplateFunction::new( - first, - Box::new(move |value| property.extract(&value)), - ))), - } - } -} - struct PropertyAndLabels<'a, C>(Property<'a, C>, Vec); fn parse_commit_keyword<'a>(