From 9c80ef561ff4a70e7ef587bdeb0b78a81dd92f9e Mon Sep 17 00:00:00 2001 From: Josh McKinney Date: Mon, 22 Jul 2024 04:24:30 -0700 Subject: [PATCH] feat(text)!: remove unnecessary lifetime from ToText trait (#1234) BREAKING CHANGE: The ToText trait no longer has a lifetime parameter. This change simplifies the trait and makes it easier implement. --- src/text/text.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/text/text.rs b/src/text/text.rs index 7f9a8780ce..1bbaeb1d26 100644 --- a/src/text/text.rs +++ b/src/text/text.rs @@ -587,9 +587,9 @@ where /// you get the `ToText` implementation for free. /// /// [`Display`]: std::fmt::Display -pub trait ToText<'a> { +pub trait ToText { /// Converts the value to a [`Text`]. - fn to_text(&self) -> Text<'a>; + fn to_text(&self) -> Text<'_>; } /// # Panics @@ -597,8 +597,8 @@ pub trait ToText<'a> { /// In this implementation, the `to_text` method panics if the `Display` implementation returns an /// error. This indicates an incorrect `Display` implementation since `fmt::Write for String` never /// returns an error itself. -impl<'a, T: fmt::Display> ToText<'a> for T { - fn to_text(&self) -> Text<'a> { +impl ToText for T { + fn to_text(&self) -> Text { Text::raw(self.to_string()) } }