Skip to content

Commit aae3d58

Browse files
arlosiTurbo87
authored andcommitted
index: Use ordered map for features
1 parent 15f0f2a commit aae3d58

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

cargo-registry-index/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ extern crate serde;
55
pub mod testing;
66

77
use anyhow::{anyhow, Context};
8-
use std::collections::HashMap;
8+
use std::collections::BTreeMap;
99
use std::io::Write;
1010
use std::path::{Path, PathBuf};
1111
use std::process::Command;
@@ -101,7 +101,7 @@ pub struct Crate {
101101
pub vers: String,
102102
pub deps: Vec<Dependency>,
103103
pub cksum: String,
104-
pub features: HashMap<String, Vec<String>>,
104+
pub features: BTreeMap<String, Vec<String>>,
105105
/// This field contains features with new, extended syntax. Specifically,
106106
/// namespaced features (`dep:`) and weak dependencies (`pkg?/feat`).
107107
///
@@ -112,7 +112,7 @@ pub struct Crate {
112112
/// will fail to load due to not being able to parse the new syntax, even
113113
/// with a `Cargo.lock` file.
114114
#[serde(skip_serializing_if = "Option::is_none")]
115-
pub features2: Option<HashMap<String, Vec<String>>>,
115+
pub features2: Option<BTreeMap<String, Vec<String>>>,
116116
pub yanked: Option<bool>,
117117
#[serde(default)]
118118
pub links: Option<String>,

src/controllers/krate/publish.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use flate2::read::GzDecoder;
44
use hex::ToHex;
55
use sha2::{Digest, Sha256};
6-
use std::collections::HashMap;
6+
use std::collections::BTreeMap;
77
use std::io::Read;
88
use std::path::Path;
99
use std::sync::Arc;
@@ -216,7 +216,7 @@ pub fn publish(req: &mut dyn RequestExt) -> EndpointResult {
216216
.uploader()
217217
.upload_crate(app.http_client(), tarball, &krate, vers)?;
218218

219-
let (features, features2): (HashMap<_, _>, HashMap<_, _>) =
219+
let (features, features2): (BTreeMap<_, _>, BTreeMap<_, _>) =
220220
features.into_iter().partition(|(_k, vals)| {
221221
!vals
222222
.iter()

src/tests/krate/publish.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use diesel::{delete, update, ExpressionMethods, QueryDsl, RunQueryDsl};
1111
use flate2::write::GzEncoder;
1212
use flate2::Compression;
1313
use http::StatusCode;
14-
use std::collections::HashMap;
14+
use std::collections::{BTreeMap, HashMap};
1515
use std::io::Read;
1616
use std::iter::FromIterator;
1717
use std::time::Duration;
@@ -953,9 +953,9 @@ fn features_version_2() {
953953
assert_eq!(crates[0].name, "foo");
954954
assert_eq!(crates[0].deps.len(), 1);
955955
assert_eq!(crates[0].v, Some(2));
956-
let features = HashMap::from_iter([("old_feat".to_string(), vec![])]);
956+
let features = BTreeMap::from_iter([("old_feat".to_string(), vec![])]);
957957
assert_eq!(crates[0].features, features);
958-
let features2 = HashMap::from_iter([(
958+
let features2 = BTreeMap::from_iter([(
959959
"new_feat".to_string(),
960960
vec!["dep:bar".to_string(), "bar?/feat".to_string()],
961961
)]);

0 commit comments

Comments
 (0)