Lint fixes (#99)
* Replace a single-character string literal with a character literal. * Use is_some() instead of comparing with Some(_). * Add code-quotes around type names in comments. * Use !...is_empty() instead of len() != 0. * Tidy up redundant returns. * Remove redundant .clone() calls. * Remove unnecessary explicit lifetime parameters. * Tidy up unnecessary '&'s. * Add parens to make operator precedence explicit. * Use debug_assert_eq instead of debug_assert with ==. * Replace a &Vec argument with a &[...]. * Replace `a = a op b` with `a op= b`. * Avoid unnecessary closures. * Avoid .iter() and .iter_mut() for iterating over containers. * Remove unneeded qualification.
This commit is contained in:
committed by
Jakob Stoklund Olesen
parent
3693735874
commit
0c7316ae28
@@ -66,7 +66,7 @@ impl Directive {
|
||||
return Err(Error::Syntax(format!("invalid variable name in regex: {}", rest)));
|
||||
}
|
||||
let var = rest[0..varlen].to_string();
|
||||
if !rest[varlen..].starts_with("=") {
|
||||
if !rest[varlen..].starts_with('=') {
|
||||
return Err(Error::Syntax(format!("expected '=' after variable '{}' in regex: {}",
|
||||
var,
|
||||
rest)));
|
||||
@@ -196,7 +196,7 @@ impl Checker {
|
||||
// Check if `pat` matches in `range`.
|
||||
state.recorder.directive(dct_idx);
|
||||
if let Some((match_begin, match_end)) = state.match_positive(pat, range)? {
|
||||
if let &Directive::Unordered(_) = dct {
|
||||
if let Directive::Unordered(_) = *dct {
|
||||
// This was an unordered unordered match.
|
||||
// Keep track of the largest matched position, but leave `last_ordered` alone.
|
||||
state.max_match = max(state.max_match, match_end);
|
||||
@@ -231,7 +231,7 @@ impl Checker {
|
||||
// Verify any pending `not:` directives after the last ordered directive.
|
||||
for (not_idx, not_begin, rx) in nots.drain(..) {
|
||||
state.recorder.directive(not_idx);
|
||||
if let Some(_) = rx.find(&text[not_begin..]) {
|
||||
if rx.find(&text[not_begin..]).is_some() {
|
||||
// Matched `not:` pattern.
|
||||
// TODO: Use matched range for an error message.
|
||||
return Ok(false);
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
//! A list of directives is typically extracted from a file containing a test case. The test case
|
||||
//! is then run through the program under test, and its output matched against the directives.
|
||||
//!
|
||||
//! See the [CheckerBuilder](struct.CheckerBuilder.html) and [Checker](struct.Checker.html) types
|
||||
//! for the main library API.
|
||||
//! See the [`CheckerBuilder`](struct.CheckerBuilder.html) and [`Checker`](struct.Checker.html)
|
||||
//! types for the main library API.
|
||||
//!
|
||||
//! # Directives
|
||||
//!
|
||||
|
||||
Reference in New Issue
Block a user