rustfmt and cleanup

This commit is contained in:
Greg 2019-06-16 16:02:31 -04:00
parent 6a31294da8
commit d225a9024e
No known key found for this signature in database
GPG key ID: 2E44FAEEDC94B1E2
3 changed files with 11 additions and 15 deletions

View file

@ -1,8 +1,6 @@
edition = "2018"
max_width = 80
wrap_comments = true
control_brace_style = "ClosingNextLine"
brace_style = "PreferSameLine"
format_strings = true
merge_imports = true
match_block_trailing_comma = true

View file

@ -18,6 +18,7 @@ jobs:
parameters:
name: rustfmt
displayName: Check formatting
rust_version: nightly
# This represents the minimum Rust version supported.
# Tests are not run as tests may require newer versions of rust.
@ -86,5 +87,4 @@ jobs:
github:
gitHubConnection: githubConnection
repositoryName: chmln/sd
isPreRelease: true

View file

@ -31,8 +31,7 @@ impl Replacer {
) -> Result<Self> {
let (look_for, replace_with) = if is_literal {
(regex::escape(&look_for), replace_with.into_bytes())
}
else {
} else {
(
look_for,
utils::unescape(&replace_with)
@ -48,20 +47,20 @@ impl Replacer {
match c {
'c' => {
regex.case_insensitive(false);
},
}
'i' => {
regex.case_insensitive(true);
},
}
'm' => {
regex.multi_line(true);
},
}
'w' => {
regex = regex::bytes::RegexBuilder::new(&format!(
"\\b{}\\b",
look_for
));
},
_ => {},
}
_ => {}
};
}
};
@ -83,8 +82,7 @@ impl Replacer {
&content,
regex::bytes::NoExpand(&self.replace_with),
)
}
else {
} else {
self.regex.replace_all(&content, &*self.replace_with)
}
}
@ -130,7 +128,7 @@ impl Replacer {
handle.write_all(&self.replace(&buffer))?;
}
Ok(())
},
}
(Source::Files(paths), true) => {
use rayon::prelude::*;
@ -139,7 +137,7 @@ impl Replacer {
.map(|p| self.replace_file(p).map_err(Error::log))
.collect::<Vec<Result<()>>>();
Ok(())
},
}
(Source::Files(paths), false) => {
let stdout = std::io::stdout();
let mut handle = stdout.lock();
@ -154,7 +152,7 @@ impl Replacer {
})
.collect::<Result<Vec<()>>>()?;
Ok(())
},
}
}
}
}