use std::fmt;
#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[allow(clippy::derived_hash_with_manual_eq)] pub struct PackageId {
repr: Box<str>,
}
impl PackageId {
pub fn new(s: impl Into<Box<str>>) -> Self {
Self { repr: s.into() }
}
pub(super) fn from_metadata(id: cargo_metadata::PackageId) -> Self {
Self {
repr: id.repr.into_boxed_str(),
}
}
pub fn repr(&self) -> &str {
&self.repr
}
}
impl fmt::Display for PackageId {
fn fmt(&self, f: &mut fmt::Formatter) -> std::fmt::Result {
fmt::Display::fmt(&self.repr, f)
}
}
impl PartialEq<&PackageId> for PackageId {
fn eq(&self, other: &&PackageId) -> bool {
self.eq(*other)
}
}
impl PartialEq<PackageId> for &PackageId {
fn eq(&self, other: &PackageId) -> bool {
(*self).eq(other)
}
}