diff --git a/Cargo.toml b/Cargo.toml index f231fc8..3d68ad7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,7 @@ hyper = "0.11.15" hyper-tls = "0.1.2" lazy_static = "1.0.0" maud = "0.17.2" -ordermap = "0.4.0" +ordermap = { version = "0.4.0", features = ["serde-1"] } relative-path = { version = "0.3.7", features = ["serde"] } route-recognizer = "0.1.12" semver = { version = "0.9.0", features = ["serde"] } diff --git a/src/models/crates.rs b/src/models/crates.rs index 07f11b7..2ebe7a8 100644 --- a/src/models/crates.rs +++ b/src/models/crates.rs @@ -1,8 +1,8 @@ use std::borrow::Borrow; -use std::collections::BTreeMap; use std::str::FromStr; use failure::Error; +use ordermap::OrderMap; use relative_path::RelativePathBuf; use semver::{Version, VersionReq}; @@ -68,9 +68,9 @@ impl CrateDep { #[derive(Clone, Debug, Default)] pub struct CrateDeps { - pub main: BTreeMap, - pub dev: BTreeMap, - pub build: BTreeMap + pub main: OrderMap, + pub dev: OrderMap, + pub build: OrderMap } #[derive(Debug)] @@ -96,9 +96,9 @@ impl AnalyzedDependency { #[derive(Debug)] pub struct AnalyzedDependencies { - pub main: BTreeMap, - pub dev: BTreeMap, - pub build: BTreeMap + pub main: OrderMap, + pub dev: OrderMap, + pub build: OrderMap } impl AnalyzedDependencies { diff --git a/src/parsers/manifest.rs b/src/parsers/manifest.rs index 0d4fda5..0b4b969 100644 --- a/src/parsers/manifest.rs +++ b/src/parsers/manifest.rs @@ -1,6 +1,5 @@ -use std::collections::BTreeMap; - use failure::Error; +use ordermap::OrderMap; use relative_path::RelativePathBuf; use semver::VersionReq; use toml; @@ -38,13 +37,13 @@ struct CargoToml { #[serde(default)] workspace: Option, #[serde(default)] - dependencies: BTreeMap, + dependencies: OrderMap, #[serde(rename = "dev-dependencies")] #[serde(default)] - dev_dependencies: BTreeMap, + dev_dependencies: OrderMap, #[serde(rename = "build-dependencies")] #[serde(default)] - build_dependencies: BTreeMap + build_dependencies: OrderMap } fn convert_dependency(cargo_dep: (String, CargoTomlDependency)) -> Option> { @@ -86,11 +85,11 @@ pub fn parse_manifest_toml(input: &str) -> Result { let crate_name = package.name.parse::()?; let dependencies = cargo_toml.dependencies - .into_iter().filter_map(convert_dependency).collect::, _>>()?; + .into_iter().filter_map(convert_dependency).collect::, _>>()?; let dev_dependencies = cargo_toml.dev_dependencies - .into_iter().filter_map(convert_dependency).collect::, _>>()?; + .into_iter().filter_map(convert_dependency).collect::, _>>()?; let build_dependencies = cargo_toml.build_dependencies - .into_iter().filter_map(convert_dependency).collect::, _>>()?; + .into_iter().filter_map(convert_dependency).collect::, _>>()?; let deps = CrateDeps { main: dependencies, diff --git a/src/server/views/html/status.rs b/src/server/views/html/status.rs index 8ac8b54..1934859 100644 --- a/src/server/views/html/status.rs +++ b/src/server/views/html/status.rs @@ -1,8 +1,7 @@ -use std::collections::BTreeMap; - use base64::display::Base64Display; use hyper::Response; use maud::{Markup, html}; +use ordermap::OrderMap; use ::engine::AnalyzeDependenciesOutcome; use ::models::crates::{CrateName, AnalyzedDependency, AnalyzedDependencies}; @@ -34,7 +33,7 @@ fn dependency_tables(crate_name: CrateName, deps: AnalyzedDependencies) -> Marku } } -fn dependency_table(title: &str, deps: BTreeMap) -> Markup { +fn dependency_table(title: &str, deps: OrderMap) -> Markup { let count_total = deps.len(); let count_outdated = deps.iter().filter(|&(_, dep)| dep.is_outdated()).count();