mirror of
https://github.com/rust-lang/cargo.git
synced 2025-09-28 11:20:36 +00:00
manual impl of hash
This commit is contained in:
parent
d8b7c072c5
commit
06811d8594
@ -1,7 +1,7 @@
|
||||
use std::cmp::Ordering;
|
||||
|
||||
/// The possible kinds of code source.
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub enum SourceKind {
|
||||
/// A git repository.
|
||||
Git(GitReference),
|
||||
@ -17,6 +17,19 @@ pub enum SourceKind {
|
||||
Directory,
|
||||
}
|
||||
|
||||
// The hash here is important for what folder packages get downloaded into.
|
||||
// Changes trigger all users to download another copy of their crates.
|
||||
// So the `stable_hash` test checks that we only change it intentionally.
|
||||
// We implement hash manually to callout the stability impact.
|
||||
impl std::hash::Hash for SourceKind {
|
||||
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
|
||||
core::mem::discriminant(self).hash(state);
|
||||
if let SourceKind::Git(git) = self {
|
||||
git.hash(state);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl SourceKind {
|
||||
pub fn protocol(&self) -> Option<&str> {
|
||||
match self {
|
||||
|
Loading…
x
Reference in New Issue
Block a user