Skip to content

Commit

Permalink
fix: use collect() instead of for loop
Browse files Browse the repository at this point in the history
  • Loading branch information
TommyCpp committed May 8, 2021
1 parent 6022ac7 commit 2bcabf3
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions opentelemetry-otlp/tests/grpc_build.rs
Expand Up @@ -40,17 +40,17 @@ fn build_grpc() {
}

fn build_content_map() -> HashMap<PathBuf, String> {
let mut map = HashMap::new();
let dict =
std::fs::read_dir("src/proto/grpcio").expect("cannot open dict of generated grpc files");

for entry in dict.into_iter().flatten() {
map.insert(
entry.path(),
std::fs::read_to_string(entry.path()).unwrap_or_else(|_| {
panic!("cannot read from file {}", entry.path().to_string_lossy())
}),
);
}
map
std::fs::read_dir("src/proto/grpcio")
.expect("cannot open dict of generated grpc files")
.into_iter()
.flatten()
.map(|entry| {
(
entry.path(),
std::fs::read_to_string(entry.path()).unwrap_or_else(|_| {
panic!("cannot read from file {}", entry.path().to_string_lossy())
}),
)
})
.collect()
}

0 comments on commit 2bcabf3

Please sign in to comment.