From 71448ff3c25db6cba8dc40191416e9e1490e7964 Mon Sep 17 00:00:00 2001 From: Shotaro Yamada Date: Sun, 1 Apr 2018 21:21:52 +0900 Subject: [PATCH] Return String instead of always returing Cow::Owned --- src/missed_spans.rs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/missed_spans.rs b/src/missed_spans.rs index 5140ac35be9..db4f01fa688 100644 --- a/src/missed_spans.rs +++ b/src/missed_spans.rs @@ -175,7 +175,7 @@ impl<'a> FmtVisitor<'a> { let mut status = SnippetStatus::new(char_pos.line); let snippet = &*match self.config.write_mode() { - WriteMode::Coverage => replace_chars(old_snippet), + WriteMode::Coverage => Cow::from(replace_chars(old_snippet)), _ => Cow::from(old_snippet), }; @@ -320,11 +320,9 @@ impl<'a> FmtVisitor<'a> { } } -fn replace_chars(string: &str) -> Cow { - Cow::from( - string - .chars() - .map(|ch| if ch.is_whitespace() { ch } else { 'X' }) - .collect::(), - ) +fn replace_chars(string: &str) -> String { + string + .chars() + .map(|ch| if ch.is_whitespace() { ch } else { 'X' }) + .collect() }