Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ddf9426

Browse files
committed
Tweak style for new WithAnsi code
1 parent 903df6d commit ddf9426

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/ansi.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -206,18 +206,19 @@ pub fn strip_ansi_codes(s: &str) -> Cow<str> {
206206
pub struct WithoutAnsi<'a> {
207207
str: &'a str,
208208
}
209+
209210
impl<'a> WithoutAnsi<'a> {
210211
pub fn new(str: &'a str) -> Self {
211212
Self { str }
212213
}
213214
}
215+
214216
impl Display for WithoutAnsi<'_> {
215217
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
216-
for str in
217-
AnsiCodeIterator::new(self.str)
218-
.filter_map(|(str, is_ansi)| if is_ansi { None } else { Some(str) })
219-
{
220-
f.write_str(str)?;
218+
for (str, is_ansi) in AnsiCodeIterator::new(self.str) {
219+
if !is_ansi {
220+
f.write_str(str)?;
221+
}
221222
}
222223
Ok(())
223224
}

0 commit comments

Comments
 (0)