Thanks to visit codestin.com Credit goes to github.com
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 903df6d commit 90ea08dCopy full SHA for 90ea08d
src/ansi.rs
@@ -206,18 +206,19 @@ pub fn strip_ansi_codes(s: &str) -> Cow<str> {
206
pub struct WithoutAnsi<'a> {
207
str: &'a str,
208
}
209
+
210
impl<'a> WithoutAnsi<'a> {
211
pub fn new(str: &'a str) -> Self {
212
Self { str }
213
214
215
216
impl Display for WithoutAnsi<'_> {
217
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
- for str in
- AnsiCodeIterator::new(self.str)
218
- .filter_map(|(str, is_ansi)| if is_ansi { None } else { Some(str) })
219
- {
220
- f.write_str(str)?;
+ for (str, is_ansi) in AnsiCodeIterator::new(self.str) {
+ if !is_ansi {
+ f.write_str(str)?;
221
+ }
222
223
Ok(())
224
0 commit comments