Commit bbd06321 authored by DCjanus's avatar DCjanus
Browse files

impl Hash for some ID type

parent 4eb8f51d
Pipeline #143792 passed with stage
......@@ -9,7 +9,7 @@ macro_rules! impl_id {
/* This bit of the macro handles the repetitive nature of creating new identifiers.
* Unfortunately, it doesn't work with serde_codegen, so until either plugins are stable or
* nightly is required, just implement things by hand.
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq)]
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct $name(u64);
*/
......
......@@ -34,7 +34,7 @@ pub type QueryParamSlice<'a> = &'a [(&'a str, &'a str)];
pub type QueryParamVec<'a> = Vec<(&'a str, &'a str)>;
#[cfg_attr(feature = "strict", serde(deny_unknown_fields))]
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq)]
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, Hash)]
/// Type-safe user ID.
pub struct UserId(u64);
impl_id!(UserId);
......@@ -152,13 +152,13 @@ pub struct Identity {
}
#[cfg_attr(feature = "strict", serde(deny_unknown_fields))]
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq)]
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, Hash)]
/// Type-safe theme ID.
pub struct ThemeId(u64);
impl_id!(ThemeId);
#[cfg_attr(feature = "strict", serde(deny_unknown_fields))]
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq)]
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, Hash)]
/// Type-safe color scheme ID.
pub struct ColorSchemeId(u64);
impl_id!(ColorSchemeId);
......@@ -279,7 +279,7 @@ impl From<UserPublic> for User {
}
#[cfg_attr(feature = "strict", serde(deny_unknown_fields))]
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq)]
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, Hash)]
/// Type-safe email ID.
pub struct EmailId(u64);
impl_id!(EmailId);
......@@ -295,7 +295,7 @@ pub struct Email {
}
#[cfg_attr(feature = "strict", serde(deny_unknown_fields))]
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq)]
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, Hash)]
/// Type-safe hook ID.
pub struct HookId(u64);
impl_id!(HookId);
......@@ -427,7 +427,7 @@ impl WebhookEvents {
}
#[cfg_attr(feature = "strict", serde(deny_unknown_fields))]
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq)]
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, Hash)]
/// Type-safe project ID.
pub struct ProjectId(u64);
impl_id!(ProjectId);
......@@ -802,7 +802,7 @@ impl From<AccessRequester> for UserBasic {
}
#[cfg_attr(feature = "strict", serde(deny_unknown_fields))]
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq)]
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, Hash)]
/// Type-safe group ID.
pub struct GroupId(u64);
impl_id!(GroupId);
......@@ -1052,7 +1052,7 @@ pub struct RepoCommitDetail {
}
#[cfg_attr(feature = "strict", serde(deny_unknown_fields))]
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq)]
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, Hash)]
/// Type-safe snippet ID.
pub struct SnippetId(u64);
impl_id!(SnippetId);
......@@ -1126,13 +1126,13 @@ pub struct DiffRefs {
}
#[cfg_attr(feature = "strict", serde(deny_unknown_fields))]
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq)]
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, Hash)]
/// Type-safe milestone ID.
pub struct MilestoneId(u64);
impl_id!(MilestoneId);
#[cfg_attr(feature = "strict", serde(deny_unknown_fields))]
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq)]
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, Hash)]
/// Type-safe milestone internal ID (internal to a project).
pub struct MilestoneInternalId(u64);
impl_id!(MilestoneInternalId);
......@@ -1214,7 +1214,7 @@ impl Milestone {
}
#[cfg_attr(feature = "strict", serde(deny_unknown_fields))]
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq)]
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, Hash)]
/// Type-safe label ID.
pub struct LabelId(u64);
impl_id!(LabelId);
......@@ -1315,13 +1315,13 @@ impl Label {
}
#[cfg_attr(feature = "strict", serde(deny_unknown_fields))]
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq)]
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, Hash)]
/// Type-safe issue ID.
pub struct IssueId(u64);
impl_id!(IssueId);
#[cfg_attr(feature = "strict", serde(deny_unknown_fields))]
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq)]
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, Hash)]
/// Type-safe issue internal ID (internal to a project).
pub struct IssueInternalId(u64);
impl_id!(IssueInternalId);
......@@ -1523,7 +1523,7 @@ pub struct IssuableTimeStats {
}
#[cfg_attr(feature = "strict", serde(deny_unknown_fields))]
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq)]
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, Hash)]
/// Type-safe external issue ID.
pub struct ExternalIssueId(u64);
......@@ -1570,13 +1570,13 @@ impl<'de> Deserialize<'de> for IssueReference {
}
#[cfg_attr(feature = "strict", serde(deny_unknown_fields))]
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq)]
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, Hash)]
/// Type-safe merge request ID.
pub struct MergeRequestId(u64);
impl_id!(MergeRequestId);
#[cfg_attr(feature = "strict", serde(deny_unknown_fields))]
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq)]
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, Hash)]
/// Type-safe merge request internal ID (internal to a project).
pub struct MergeRequestInternalId(u64);
impl_id!(MergeRequestInternalId);
......@@ -1877,7 +1877,7 @@ impl From<MergeRequestChanges> for MergeRequest {
}
#[cfg_attr(feature = "strict", serde(deny_unknown_fields))]
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq)]
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, Hash)]
/// Type-safe SSH key ID.
pub struct SshKeyId(u64);
impl_id!(SshKeyId);
......@@ -1957,7 +1957,7 @@ pub enum NoteableInternalId {
}
#[cfg_attr(feature = "strict", serde(deny_unknown_fields))]
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq)]
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, Hash)]
/// Type-safe note (comment) ID.
pub struct NoteId(u64);
impl_id!(NoteId);
......@@ -2047,7 +2047,7 @@ impl Note {
}
#[cfg_attr(feature = "strict", serde(deny_unknown_fields))]
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq)]
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, Hash)]
/// Type-safe award ID.
pub struct AwardId(u64);
impl_id!(AwardId);
......@@ -2149,7 +2149,7 @@ pub struct CommitNote {
}
#[cfg_attr(feature = "strict", serde(deny_unknown_fields))]
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq)]
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, Hash)]
/// Type-safe commit status ID.
pub struct CommitStatusId(u64);
impl_id!(CommitStatusId);
......@@ -2369,7 +2369,7 @@ impl Namespace {
}
#[cfg_attr(feature = "strict", serde(deny_unknown_fields))]
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq)]
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, Hash)]
/// Type-safe runner ID.
pub struct RunnerId(u64);
impl_id!(RunnerId);
......@@ -2401,7 +2401,7 @@ pub struct JobArtifactFile {
}
#[cfg_attr(feature = "strict", serde(deny_unknown_fields))]
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq)]
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, Hash)]
/// Type-safe job ID.
pub struct JobId(u64);
impl_id!(JobId);
......@@ -2441,7 +2441,7 @@ pub struct Job {
}
#[cfg_attr(feature = "strict", serde(deny_unknown_fields))]
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq)]
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, Hash)]
/// Type-safe pipeline ID.
pub struct PipelineId(u64);
impl_id!(PipelineId);
......@@ -2464,7 +2464,7 @@ pub struct PipelineBasic {
}
#[cfg_attr(feature = "strict", serde(deny_unknown_fields))]
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq)]
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, Hash)]
/// Type-safe label event ID.
pub struct LabelEventId(u64);
impl_id!(LabelEventId);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment