Skip to content
This repository has been archived by the owner on Nov 8, 2023. It is now read-only.

Commit

Permalink
Merge "rust: checksum: Use BTreeMap instead of HashMap" into main
Browse files Browse the repository at this point in the history
  • Loading branch information
maurer authored and Gerrit Code Review committed Jan 7, 2025
2 parents e428126 + 4a93f96 commit 1b15809
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions tools/external_crates/checksum/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
//! very similar to .cargo-checksum.json
use std::{
collections::HashMap,
collections::BTreeMap,
fs::{remove_file, write, File},
io::{self, BufReader, Read},
path::{Path, PathBuf, StripPrefixError},
Expand All @@ -31,7 +31,8 @@ use walkdir::WalkDir;
#[derive(Serialize, Deserialize)]
struct Checksum {
package: Option<String>,
files: HashMap<String, String>,
// BTreeMap keeps this reproducible
files: BTreeMap<String, String>,
}

#[allow(missing_docs)]
Expand Down Expand Up @@ -62,7 +63,7 @@ pub fn generate(crate_dir: impl AsRef<Path>) -> Result<(), ChecksumError> {
if checksum_file.exists() {
remove_file(&checksum_file)?;
}
let mut checksum = Checksum { package: None, files: HashMap::new() };
let mut checksum = Checksum { package: None, files: BTreeMap::new() };
for entry in WalkDir::new(crate_dir).follow_links(true) {
let entry = entry?;
if entry.path().is_dir() {
Expand Down

0 comments on commit 1b15809

Please sign in to comment.