cargo clippy --fix

This commit is contained in:
Henry Schimke
2023-01-27 15:24:24 -06:00
parent 58e6827e89
commit 42d40de755
86 changed files with 196 additions and 335 deletions

View File

@@ -89,7 +89,7 @@ fn matchMultipleValuePrefix(prefix: &str, rawText: &str) -> Vec<String> {
for i in 1..=3 {
// for (int i = 1; i <= 3; i++) {
let value = ResultParser::matchSinglePrefixedField(
&format!("{}{}:", prefix, i),
&format!("{prefix}{i}:"),
rawText,
'\r',
true,

View File

@@ -123,6 +123,6 @@ fn buildName(firstName: &str, lastName: &str) -> String {
} else if lastName.is_empty() {
firstName.to_owned()
} else {
format!("{} {}", firstName, lastName)
format!("{firstName} {lastName}")
}
}

View File

@@ -196,8 +196,7 @@ impl CalendarParsedRXingResult {
return match Utc.datetime_from_str(&when, "%Y%m%dT%H%M%SZ") {
Ok(dtm) => Ok(dtm.with_timezone(&Utc).timestamp()),
Err(e) => Err(Exceptions::ParseException(Some(format!(
"couldn't parse string: {}",
e
"couldn't parse string: {e}"
)))),
};
// let dtm = DateTime::parse_from_str(&when, "%Y%m%dT%H%M%S").unwrap().with_timezone(&Utc);
@@ -219,16 +218,14 @@ impl CalendarParsedRXingResult {
Ok(time_zone) => time_zone,
Err(e) => {
return Err(Exceptions::ParseException(Some(format!(
"couldn't parse timezone '{}': {}",
tz_part, e
"couldn't parse timezone '{tz_part}': {e}"
))))
}
};
return match Utc.datetime_from_str(time_part, "%Y%m%dT%H%M%S") {
Ok(dtm) => Ok(dtm.with_timezone(&tz_parsed).timestamp()),
Err(e) => Err(Exceptions::ParseException(Some(format!(
"couldn't parse string: {}",
e
"couldn't parse string: {e}"
)))),
};
}
@@ -238,8 +235,7 @@ impl CalendarParsedRXingResult {
return match Utc.datetime_from_str(&when, "%Y%m%dT%H%M%S") {
Ok(dtm) => Ok(dtm.timestamp()),
Err(e) => Err(Exceptions::ParseException(Some(format!(
"couldn't parse local time: {}",
e
"couldn't parse local time: {e}"
)))),
};
}
@@ -300,8 +296,7 @@ impl CalendarParsedRXingResult {
Ok(dtm.timestamp())
} else {
Err(Exceptions::ParseException(Some(format!(
"Couldn't parse {}",
dateTimeString
"Couldn't parse {dateTimeString}"
))))
}
// DateFormat format = new SimpleDateFormat("yyyyMMdd'T'HHmmss", Locale.ENGLISH);

View File

@@ -78,7 +78,7 @@ fn testRSSExpanded() {
let ev = epr_res.getUncommonAIs().get(k).unwrap();
assert_eq!(v, ev);
} else {
panic!("key not found {}", k)
panic!("key not found {k}")
}
}
// assert_eq!(&uncommonAIs, epr_res.getUncommonAIs());

View File

@@ -49,7 +49,7 @@ fn doTest(contents: &str, number: &str, title: &str) {
if let ParsedClientResult::TelResult(telRXingResult) = result {
assert_eq!(number, telRXingResult.getNumber());
assert_eq!(title, telRXingResult.getTitle());
assert_eq!(format!("tel:{}", number), telRXingResult.getTelURI());
assert_eq!(format!("tel:{number}"), telRXingResult.getTelURI());
} else {
panic!("wrong return type, expected TelResult");
}

View File

@@ -36,7 +36,7 @@ pub fn parse(theRXingResult: &crate::RXingResult) -> Option<ParsedClientResult>
}
// Normalize "TEL:" to "tel:"
let telURI = if let Some(stripped) = rawText.strip_prefix("TEL:") {
format!("tel:{}", stripped)
format!("tel:{stripped}")
} else {
rawText.clone()
};

View File

@@ -182,7 +182,7 @@ pub fn matchVCardPrefixedField(
// At start or after newline, match prefix, followed by optional metadata
// (led by ;) ultimately ending in colon
let matcher_primary = Regex::new(&format!("(?:^|\\n)(?i:{})(?:;([^:]*))?:", prefix)).unwrap();
let matcher_primary = Regex::new(&format!("(?:^|\\n)(?i:{prefix})(?:;([^:]*))?:")).unwrap();
// let matcher_primary = Regex::new(&format!("(?:^|\n){}(.*)", prefix)).unwrap();
//let lower_case_raw_text = rawText.to_lowercase();

View File

@@ -134,7 +134,7 @@ fn matchSingleVCardPrefixedField(prefix: &str, rawText: &str) -> String {
"".to_owned()
};
let root_time = values.last().unwrap().clone();
format!("{}{}", root_time, tz_mod)
format!("{root_time}{tz_mod}")
}
} else {
"".to_owned()