Skip to content

Commit

Permalink
feat(text)!: remove unnecessary lifetime from ToText trait (#1234)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: The ToText trait no longer has a lifetime parameter.
This change simplifies the trait and makes it easier implement.
  • Loading branch information
joshka authored Jul 22, 2024
1 parent 6ce447c commit c34fb77
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/text/text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -587,18 +587,18 @@ 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
///
/// 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<T: fmt::Display> ToText for T {
fn to_text(&self) -> Text {
Text::raw(self.to_string())
}
}
Expand Down

0 comments on commit c34fb77

Please sign in to comment.