From c7c65ef671852e872d7d7202db5b1fb906aebfa7 Mon Sep 17 00:00:00 2001 From: Eunchong Yu Date: Sun, 19 Aug 2018 10:39:20 +0900 Subject: [PATCH] Fix infinite recursive calls It reverts #137. --- src/proto/colors.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/proto/colors.rs b/src/proto/colors.rs index ba2afb3..8e20e33 100644 --- a/src/proto/colors.rs +++ b/src/proto/colors.rs @@ -102,10 +102,10 @@ impl FormattedStringExt for str { impl FormattedStringExt for String { fn is_formatted(&self) -> bool { - (&self[..]).is_formatted() + self.as_str().is_formatted() } fn strip_formatting(&self) -> Cow { - (&self[..]).strip_formatting() + self.as_str().strip_formatting() } } @@ -117,6 +117,10 @@ mod test { fn test_strip_bold() { assert_eq!("l\x02ol".strip_formatting(), "lol"); } + #[test] + fn test_strip_bold_from_string() { + assert_eq!(String::from("l\x02ol").strip_formatting(), "lol"); + } #[test] fn test_strip_fg_color() {