mirror of
https://github.com/rust-lang/cargo.git
synced 2025-09-28 11:20:36 +00:00
Add pointer equality to PartialEq for PackageId
This commit is contained in:
parent
0abfcc0dd4
commit
a73c5171f8
@ -3,6 +3,7 @@ use std::fmt::{self, Formatter};
|
||||
use std::hash;
|
||||
use std::hash::Hash;
|
||||
use std::path::Path;
|
||||
use std::ptr;
|
||||
use std::sync::Mutex;
|
||||
|
||||
use semver;
|
||||
@ -18,7 +19,7 @@ lazy_static! {
|
||||
}
|
||||
|
||||
/// Identifier for a specific version of a package in a specific source.
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
|
||||
#[derive(Clone, Copy, Eq, Hash, PartialOrd, Ord)]
|
||||
pub struct PackageId {
|
||||
inner: &'static PackageIdInner,
|
||||
}
|
||||
@ -96,6 +97,15 @@ impl<'de> de::Deserialize<'de> for PackageId {
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialEq for PackageId {
|
||||
fn eq(&self, other: &PackageId) -> bool {
|
||||
if ptr::eq(self.inner, other.inner) {
|
||||
return true;
|
||||
}
|
||||
(*self.inner).eq(&*other.inner)
|
||||
}
|
||||
}
|
||||
|
||||
impl PackageId {
|
||||
pub fn new<T: ToSemver>(name: &str, version: T, sid: SourceId) -> CargoResult<PackageId> {
|
||||
let v = version.to_semver()?;
|
||||
|
Loading…
x
Reference in New Issue
Block a user