Skip to content

Commit

Permalink
Apply all clippy suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
DrChat committed Nov 8, 2022
1 parent 2a44bfd commit 6d13009
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
24 changes: 12 additions & 12 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use crate::symsrv::{DownloadError, DownloadStatus, SymContext, SymFileInfo};
mod pe;
mod symsrv;

const USAGE: &'static str = "Usage:
const USAGE: &str = "Usage:
pdblister [manifest | download | filestore | clean] <filepath>
Expand Down Expand Up @@ -298,7 +298,7 @@ impl FromStr for ManifestEntry {
type Err = anyhow::Error;

fn from_str(s: &str) -> Result<Self, Self::Err> {
let elements = s.split(",").collect::<Vec<_>>();
let elements = s.split(',').collect::<Vec<_>>();
if elements.len() != 3 {
anyhow::bail!("Invalid manifest line: \"{s}\"");
}
Expand Down Expand Up @@ -384,7 +384,7 @@ pub async fn download_manifest(srvstr: String, files: Vec<String>) -> anyhow::Re
println!("{} files already downloaded", ok_exists);
println!("{} files downloaded successfully", ok);

return Ok(());
Ok(())
}

async fn run() -> anyhow::Result<()> {
Expand Down Expand Up @@ -436,7 +436,7 @@ async fn run() -> anyhow::Result<()> {
for task in tasks {
if let Some(e) = task.await.unwrap() {
output_file
.write(&format!("{}\n", &e).as_bytes())
.write(format!("{}\n", &e).as_bytes())
.await
.context("Failed to write to output manifest file")?;
}
Expand All @@ -448,20 +448,20 @@ async fn run() -> anyhow::Result<()> {
fd.read_to_string(&mut buf).expect("Failed to read file");

/* Split the file into lines and collect into a vector */
let mut lines: Vec<String> = buf.lines().map(|l| String::from(l)).collect();
let mut lines: Vec<String> = buf.lines().map(String::from).collect();

/* If there is nothing to download, return out early */
if lines.len() == 0 {
print!("Nothing to download\n");
if lines.is_empty() {
println!("Nothing to download");
return Ok(());
}

print!("Original manifest has {} PDBs\n", lines.len());
println!("Original manifest has {} PDBs", lines.len());

lines.sort();
lines.dedup();

print!("Deduped manifest has {} PDBs\n", lines.len());
println!("Deduped manifest has {} PDBs", lines.len());

match download_manifest(args[2].clone(), lines).await {
Ok(_) => println!("Success!"),
Expand Down Expand Up @@ -502,8 +502,8 @@ async fn run() -> anyhow::Result<()> {
.await
.expect("Failed to create filestore directory");

if let Err(_) = tokio::fs::copy(&e.path(), fsname).await {
print!("Failed to copy file {:?}\n", &e.path());
if let Err(err) = tokio::fs::copy(&e.path(), fsname).await {
println!("Failed to copy file {:?}: {err:#}", &e.path());
}
}
}
Expand All @@ -520,7 +520,7 @@ async fn run() -> anyhow::Result<()> {
print!("{}", USAGE);
}

print!("Time elapsed: {:.3} seconds\n", it.elapsed().as_secs_f64());
println!("Time elapsed: {:.3} seconds", it.elapsed().as_secs_f64());
Ok(())
}

Expand Down
6 changes: 3 additions & 3 deletions src/symsrv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ async fn download_single(
.context("failed to get file.ptr contents")?;

// FIXME: Would prefer not to unwrap the iterator results...
let mut url_iter = url.split(":");
let mut url_iter = url.split(':');
let url_type = url_iter.next().unwrap();
let url = url_iter.next().unwrap();

Expand Down Expand Up @@ -391,7 +391,7 @@ fn connect_server(srv: &SymSrv) -> anyhow::Result<reqwest::Client> {
let pat = url
.password()
.map(|p| p.to_string())
.or(std::env::var("ADO_PAT").ok())
.or_else(|| std::env::var("ADO_PAT").ok())
.context("PAT not specified for ADO")?;
if url.scheme() != "https" {
anyhow::bail!("This URL must be over https!");
Expand Down Expand Up @@ -427,7 +427,7 @@ impl SymContext {
// Couple the servers with a reqwest client.
let servers = servers
.0
.into_iter()
.iter()
.map(|s| (s.clone(), connect_server(s).unwrap()))
.collect::<Box<[_]>>();

Expand Down

0 comments on commit 6d13009

Please sign in to comment.