mirror of
https://github.com/martinvonz/jj.git
synced 2025-05-11 18:32:51 +00:00
templater: inline old impl_core_wrap_property_fns!() macro
There aren't many users of this macro, and the set of Template-like types wouldn't grow.
This commit is contained in:
parent
f5c36d5420
commit
1194b94e51
@ -90,6 +90,7 @@ use crate::template_parser::TemplateParseError;
|
||||
use crate::template_parser::TemplateParseResult;
|
||||
use crate::templater;
|
||||
use crate::templater::BoxedTemplateProperty;
|
||||
use crate::templater::ListTemplate;
|
||||
use crate::templater::PlainTextFormattedProperty;
|
||||
use crate::templater::SizeHint;
|
||||
use crate::templater::Template;
|
||||
@ -398,7 +399,13 @@ template_builder::impl_property_wrappers!(<'repo> CommitTemplatePropertyKind<'re
|
||||
});
|
||||
|
||||
impl<'repo> CoreTemplatePropertyVar<'repo> for CommitTemplatePropertyKind<'repo> {
|
||||
template_builder::impl_core_wrap_property_fns!('repo, CommitTemplatePropertyKind::Core);
|
||||
fn wrap_template(template: Box<dyn Template + 'repo>) -> Self {
|
||||
CommitTemplatePropertyKind::Core(CoreTemplatePropertyKind::wrap_template(template))
|
||||
}
|
||||
|
||||
fn wrap_list_template(template: Box<dyn ListTemplate + 'repo>) -> Self {
|
||||
CommitTemplatePropertyKind::Core(CoreTemplatePropertyKind::wrap_list_template(template))
|
||||
}
|
||||
|
||||
fn type_name(&self) -> &'static str {
|
||||
match self {
|
||||
|
@ -28,6 +28,7 @@ use crate::template_parser::FunctionCallNode;
|
||||
use crate::template_parser::TemplateDiagnostics;
|
||||
use crate::template_parser::TemplateParseResult;
|
||||
use crate::templater::BoxedTemplateProperty;
|
||||
use crate::templater::ListTemplate;
|
||||
use crate::templater::Template;
|
||||
|
||||
/// General-purpose template language for basic value types.
|
||||
@ -160,7 +161,13 @@ macro_rules! impl_self_property_wrapper {
|
||||
pub(crate) use impl_self_property_wrapper;
|
||||
|
||||
impl<'a, C> CoreTemplatePropertyVar<'a> for GenericTemplatePropertyKind<'a, C> {
|
||||
template_builder::impl_core_wrap_property_fns!('a, GenericTemplatePropertyKind::Core);
|
||||
fn wrap_template(template: Box<dyn Template + 'a>) -> Self {
|
||||
GenericTemplatePropertyKind::Core(CoreTemplatePropertyKind::wrap_template(template))
|
||||
}
|
||||
|
||||
fn wrap_list_template(template: Box<dyn ListTemplate + 'a>) -> Self {
|
||||
GenericTemplatePropertyKind::Core(CoreTemplatePropertyKind::wrap_list_template(template))
|
||||
}
|
||||
|
||||
fn type_name(&self) -> &'static str {
|
||||
match self {
|
||||
|
@ -38,6 +38,7 @@ use crate::template_parser::FunctionCallNode;
|
||||
use crate::template_parser::TemplateDiagnostics;
|
||||
use crate::template_parser::TemplateParseResult;
|
||||
use crate::templater::BoxedTemplateProperty;
|
||||
use crate::templater::ListTemplate;
|
||||
use crate::templater::PlainTextFormattedProperty;
|
||||
use crate::templater::Template;
|
||||
use crate::templater::TemplateFormatter;
|
||||
@ -148,7 +149,13 @@ template_builder::impl_property_wrappers!(OperationTemplatePropertyKind {
|
||||
});
|
||||
|
||||
impl CoreTemplatePropertyVar<'static> for OperationTemplatePropertyKind {
|
||||
template_builder::impl_core_wrap_property_fns!('static, OperationTemplatePropertyKind::Core);
|
||||
fn wrap_template(template: Box<dyn Template>) -> Self {
|
||||
OperationTemplatePropertyKind::Core(CoreTemplatePropertyKind::wrap_template(template))
|
||||
}
|
||||
|
||||
fn wrap_list_template(template: Box<dyn ListTemplate>) -> Self {
|
||||
OperationTemplatePropertyKind::Core(CoreTemplatePropertyKind::wrap_list_template(template))
|
||||
}
|
||||
|
||||
fn type_name(&self) -> &'static str {
|
||||
match self {
|
||||
|
@ -93,28 +93,6 @@ pub trait TemplateLanguage<'a> {
|
||||
) -> TemplateParseResult<Self::Property>;
|
||||
}
|
||||
|
||||
/// Implements `CoreTemplatePropertyVar::wrap_template()` functions.
|
||||
///
|
||||
/// - `impl_core_wrap_property_fns('a)` for `CoreTemplatePropertyKind`,
|
||||
/// - `impl_core_wrap_property_fns('a, MyKind::Core)` for `MyKind::Core(..)`.
|
||||
macro_rules! impl_core_wrap_property_fns {
|
||||
($a:lifetime) => {
|
||||
$crate::template_builder::impl_core_wrap_property_fns!($a, std::convert::identity);
|
||||
};
|
||||
($a:lifetime, $outer:path) => {
|
||||
fn wrap_template(template: Box<dyn $crate::templater::Template + $a>) -> Self {
|
||||
use $crate::template_builder::CoreTemplatePropertyKind as Kind;
|
||||
$outer(Kind::Template(template))
|
||||
}
|
||||
fn wrap_list_template(template: Box<dyn $crate::templater::ListTemplate + $a>) -> Self {
|
||||
use $crate::template_builder::CoreTemplatePropertyKind as Kind;
|
||||
$outer(Kind::ListTemplate(template))
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
pub(crate) use impl_core_wrap_property_fns;
|
||||
|
||||
/// Implements [`WrapTemplateProperty<'a, O>`] for property types.
|
||||
///
|
||||
/// - `impl_property_wrappers!(Kind { Foo(Foo), FooList(Vec<Foo>), .. });` to
|
||||
@ -256,7 +234,13 @@ pub(crate) use impl_core_property_wrappers;
|
||||
impl_core_property_wrappers!(<'a> CoreTemplatePropertyKind<'a>);
|
||||
|
||||
impl<'a> CoreTemplatePropertyVar<'a> for CoreTemplatePropertyKind<'a> {
|
||||
impl_core_wrap_property_fns!('a);
|
||||
fn wrap_template(template: Box<dyn Template + 'a>) -> Self {
|
||||
CoreTemplatePropertyKind::Template(template)
|
||||
}
|
||||
|
||||
fn wrap_list_template(template: Box<dyn ListTemplate + 'a>) -> Self {
|
||||
CoreTemplatePropertyKind::ListTemplate(template)
|
||||
}
|
||||
|
||||
fn type_name(&self) -> &'static str {
|
||||
match self {
|
||||
|
Loading…
x
Reference in New Issue
Block a user