Skip to content

Commit

Permalink
avoid broken pipe error when piping to head or similar
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianHicks committed Jan 24, 2023
1 parent 1f892de commit 2606fc4
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/main.rs
Expand Up @@ -33,9 +33,15 @@ impl Opts {
.calculate_pagerank(&links)
.wrap_err("could not calculate pagerank")?;

for (node, score) in pagerank.nodes() {
println!("{score:.3}\t{node}");
}
println!(
"{}",
pagerank
.nodes()
.iter()
.map(|(node, score)| format!("{score:.3}\t{node}"))
.collect::<Vec<String>>()
.join("\n")
);

Ok(())
}
Expand Down

0 comments on commit 2606fc4

Please sign in to comment.