]> git.lizzy.rs Git - rust.git/blob - src/tools/rustfmt/src/coverage.rs
Rollup merge of #85852 - m-ou-se:machineapplicable-docs, r=nikomatsakis
[rust.git] / src / tools / rustfmt / src / coverage.rs
1 use crate::{Config, EmitMode};
2 use std::borrow::Cow;
3
4 pub(crate) fn transform_missing_snippet<'a>(config: &Config, string: &'a str) -> Cow<'a, str> {
5     match config.emit_mode() {
6         EmitMode::Coverage => Cow::from(replace_chars(string)),
7         _ => Cow::from(string),
8     }
9 }
10
11 fn replace_chars(s: &str) -> String {
12     s.chars()
13         .map(|ch| if ch.is_whitespace() { ch } else { 'X' })
14         .collect()
15 }