mirror of
https://github.com/rust-lang/cargo.git
synced 2025-10-01 11:30:39 +00:00
manual impl of hash
This commit is contained in:
parent
d8b7c072c5
commit
06811d8594
@ -1,7 +1,7 @@
|
|||||||
use std::cmp::Ordering;
|
use std::cmp::Ordering;
|
||||||
|
|
||||||
/// The possible kinds of code source.
|
/// The possible kinds of code source.
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
pub enum SourceKind {
|
pub enum SourceKind {
|
||||||
/// A git repository.
|
/// A git repository.
|
||||||
Git(GitReference),
|
Git(GitReference),
|
||||||
@ -17,6 +17,19 @@ pub enum SourceKind {
|
|||||||
Directory,
|
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 {
|
impl SourceKind {
|
||||||
pub fn protocol(&self) -> Option<&str> {
|
pub fn protocol(&self) -> Option<&str> {
|
||||||
match self {
|
match self {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user