Skip to content

Commit

Permalink
manifest: Implement Hash directly on Component
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Silverstone <[email protected]>
  • Loading branch information
kinnison committed Sep 28, 2019
1 parent d4b64aa commit 1493499
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/dist/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use crate::utils::toml_utils::*;

use crate::dist::dist::{Profile, TargetTriple};
use std::collections::HashMap;
use std::hash::{Hash, Hasher};
use std::str::FromStr;

pub const SUPPORTED_MANIFEST_VERSIONS: [&str; 1] = ["2"];
Expand Down Expand Up @@ -56,7 +57,7 @@ pub struct PackageBins {
pub xz_hash: Option<String>,
}

#[derive(Clone, Debug, Eq, Ord, PartialOrd, Hash)]
#[derive(Clone, Debug, Eq, Ord, PartialOrd)]
pub struct Component {
pkg: String,
pub target: Option<TargetTriple>,
Expand All @@ -71,6 +72,16 @@ impl PartialEq for Component {
}
}

impl Hash for Component {
fn hash<H>(&self, hasher: &mut H)
where
H: Hasher,
{
self.pkg.hash(hasher);
self.target.hash(hasher);
}
}

impl Manifest {
pub fn parse(data: &str) -> Result<Self> {
let value = toml::from_str(data).map_err(ErrorKind::Parsing)?;
Expand Down

0 comments on commit 1493499

Please sign in to comment.