clippy --fix

This commit is contained in:
Christien Rioux
2023-09-17 14:14:39 -04:00
parent 6a65b9adee
commit 8a1260ed48
11 changed files with 51 additions and 65 deletions

View File

@@ -3,7 +3,7 @@ use std::process::{Command, Stdio};
fn search_file<T: AsRef<str>, P: AsRef<str>>(start: T, name: P) -> Option<PathBuf> {
let start_path = PathBuf::from(start.as_ref()).canonicalize().ok();
let mut path = start_path.as_ref().map(|x| x.as_path());
let mut path = start_path.as_deref();
while let Some(some_path) = path {
let file_path = some_path.join(name.as_ref());
if file_path.exists() {
@@ -18,10 +18,8 @@ fn get_desired_capnp_version_string() -> String {
let capnp_path = search_file(env!("CARGO_MANIFEST_DIR"), ".capnp_version")
.expect("should find .capnp_version file");
std::fs::read_to_string(&capnp_path)
.expect(&format!(
"can't read .capnp_version file here: {:?}",
capnp_path
))
.unwrap_or_else(|_| panic!("can't read .capnp_version file here: {:?}",
capnp_path))
.trim()
.to_owned()
}
@@ -47,10 +45,8 @@ fn get_desired_protoc_version_string() -> String {
let protoc_path = search_file(env!("CARGO_MANIFEST_DIR"), ".protoc_version")
.expect("should find .protoc_version file");
std::fs::read_to_string(&protoc_path)
.expect(&format!(
"can't read .protoc_version file here: {:?}",
protoc_path
))
.unwrap_or_else(|_| panic!("can't read .protoc_version file here: {:?}",
protoc_path))
.trim()
.to_owned()
}
@@ -80,10 +76,10 @@ fn main() {
// Check capnp version
let desired_capnp_major_version =
usize::from_str_radix(desired_capnp_version_string.split_once(".").unwrap().0, 10)
usize::from_str_radix(desired_capnp_version_string.split_once('.').unwrap().0, 10)
.expect("should be valid int");
if usize::from_str_radix(capnp_version_string.split_once(".").unwrap().0, 10)
if usize::from_str_radix(capnp_version_string.split_once('.').unwrap().0, 10)
.expect("should be valid int")
!= desired_capnp_major_version
{
@@ -100,9 +96,9 @@ fn main() {
// Check protoc version
let desired_protoc_major_version =
usize::from_str_radix(desired_protoc_version_string.split_once(".").unwrap().0, 10)
usize::from_str_radix(desired_protoc_version_string.split_once('.').unwrap().0, 10)
.expect("should be valid int");
if usize::from_str_radix(protoc_version_string.split_once(".").unwrap().0, 10)
if usize::from_str_radix(protoc_version_string.split_once('.').unwrap().0, 10)
.expect("should be valid int")
< desired_protoc_major_version
{