tidy: Use chars for single-character patterns
Fixes the clippy "single_char_pattern" lint, and (marginally) improves performance.
This commit is contained in:
parent
571a624aa9
commit
cd51523715
5 changed files with 12 additions and 12 deletions
|
|
@ -67,7 +67,7 @@ fn verify(tomlfile: &Path, libfile: &Path, bad: &mut bool) {
|
|||
};
|
||||
let mut lines = deps.lines().peekable();
|
||||
while let Some(line) = lines.next() {
|
||||
if line.starts_with("[") {
|
||||
if line.starts_with('[') {
|
||||
break
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ pub fn check(path: &Path, bad: &mut bool) {
|
|||
}
|
||||
|
||||
let mut search = line;
|
||||
while let Some(i) = search.find("E") {
|
||||
while let Some(i) = search.find('E') {
|
||||
search = &search[i + 1..];
|
||||
let code = if search.len() > 4 {
|
||||
search[..4].parse::<u32>()
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ pub fn check(path: &Path, bad: &mut bool) {
|
|||
}
|
||||
|
||||
// extract source value
|
||||
let parts: Vec<&str> = line.splitn(2, "=").collect();
|
||||
let parts: Vec<&str> = line.splitn(2, '=').collect();
|
||||
let source = parts[1].trim();
|
||||
|
||||
// ensure source is whitelisted
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ pub fn check(path: &Path, bad: &mut bool, quiet: bool) {
|
|||
return;
|
||||
}
|
||||
|
||||
let filen_underscore = filename.replace("-","_").replace(".rs","");
|
||||
let filen_underscore = filename.replace('-',"_").replace(".rs","");
|
||||
let filename_is_gate_test = test_filen_gate(&filen_underscore, &mut features);
|
||||
|
||||
contents.truncate(0);
|
||||
|
|
@ -332,11 +332,11 @@ fn map_lib_features(base_src_path: &Path,
|
|||
f.tracking_issue = find_attr_val(line, "issue")
|
||||
.map(|s| s.parse().unwrap());
|
||||
}
|
||||
if line.ends_with("]") {
|
||||
if line.ends_with(']') {
|
||||
mf(Ok((name, f.clone())), file, i + 1);
|
||||
} else if !line.ends_with(",") && !line.ends_with("\\") {
|
||||
} else if !line.ends_with(',') && !line.ends_with('\\') {
|
||||
// We need to bail here because we might have missed the
|
||||
// end of a stability attribute above because the "]"
|
||||
// end of a stability attribute above because the ']'
|
||||
// might not have been at the end of the line.
|
||||
// We could then get into the very unfortunate situation that
|
||||
// we continue parsing the file assuming the current stability
|
||||
|
|
@ -394,7 +394,7 @@ fn map_lib_features(base_src_path: &Path,
|
|||
has_gate_test: false,
|
||||
tracking_issue,
|
||||
};
|
||||
if line.contains("]") {
|
||||
if line.contains(']') {
|
||||
mf(Ok((feature_name, feature)), file, i + 1);
|
||||
} else {
|
||||
becoming_feature = Some((feature_name.to_owned(), feature));
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ fn line_is_url(line: &str) -> bool {
|
|||
(EXP_COMMENT_START, "//!") => state = EXP_LINK_LABEL_OR_URL,
|
||||
|
||||
(EXP_LINK_LABEL_OR_URL, w)
|
||||
if w.len() >= 4 && w.starts_with("[") && w.ends_with("]:")
|
||||
if w.len() >= 4 && w.starts_with('[') && w.ends_with("]:")
|
||||
=> state = EXP_URL,
|
||||
|
||||
(EXP_LINK_LABEL_OR_URL, w)
|
||||
|
|
@ -128,13 +128,13 @@ pub fn check(path: &Path, bad: &mut bool) {
|
|||
&& !long_line_is_ok(line) {
|
||||
err(&format!("line longer than {} chars", COLS));
|
||||
}
|
||||
if line.contains("\t") && !skip_tab {
|
||||
if line.contains('\t') && !skip_tab {
|
||||
err("tab character");
|
||||
}
|
||||
if !skip_end_whitespace && (line.ends_with(" ") || line.ends_with("\t")) {
|
||||
if !skip_end_whitespace && (line.ends_with(' ') || line.ends_with('\t')) {
|
||||
err("trailing whitespace");
|
||||
}
|
||||
if line.contains("\r") && !skip_cr {
|
||||
if line.contains('\r') && !skip_cr {
|
||||
err("CR character");
|
||||
}
|
||||
if filename != "style.rs" {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue