From 13e0d012cee23f024618c7fb1571357422043cc7 Mon Sep 17 00:00:00 2001 From: Max Sharnoff Date: Mon, 6 Jul 2020 18:46:43 +0100 Subject: [PATCH] Implement styler traits for `&'a str` (#449) --- src/style.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/style.rs b/src/style.rs index 9fa90e6..6773725 100644 --- a/src/style.rs +++ b/src/style.rs @@ -160,13 +160,23 @@ where } impl_colorize!(String); -impl_colorize!(&'static str); impl_colorize!(char); +// We do actually need the parentheses here because the macro doesn't work without them otherwise +// This is probably a bug somewhere in the compiler, but it isn't that big a deal. +#[allow(unused_parens)] +impl<'a> Colorize<&'a str> for &'a str { + impl_colorize_callback!(def_color_base!((&'a str))); +} + impl_styler!(String); -impl_styler!(&'static str); impl_styler!(char); +#[allow(unused_parens)] +impl<'a> Styler<&'a str> for &'a str { + impl_styler_callback!(def_attr_base!((&'a str))); +} + /// Returns available color count. /// /// # Notes