From 0a1722e16ddfe33b33e0af16e5b37626a72d37d9 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Thu, 13 Feb 2025 10:15:33 +0100 Subject: [PATCH] rust: use `#[default]` now that the minimum is 1.63 --- src/api/common.rs | 33 ++++--------------- src/api/groups/groups.rs | 11 ++----- src/api/groups/projects/projects.rs | 11 ++----- src/api/groups/projects/shared.rs | 11 ++----- src/api/groups/subgroups/subgroups.rs | 11 ++----- src/api/helpers.rs | 11 ++----- src/api/issues.rs | 11 ++----- src/api/merge_requests/merge_request.rs | 11 ++----- src/api/paged/pagination.rs | 11 ++----- src/api/projects/create.rs | 11 ++----- src/api/projects/packages/generic/upload.rs | 11 ++----- src/api/projects/pipelines/create.rs | 11 ++----- src/api/projects/pipelines/pipelines.rs | 11 ++----- src/api/projects/projects.rs | 11 ++----- src/api/projects/releases/links/common.rs | 11 ++----- src/api/projects/releases/releases.rs | 11 ++----- .../projects/repository/commits/commits.rs | 11 ++----- src/api/projects/repository/commits/create.rs | 10 ++---- .../repository/contributors/contributors.rs | 11 ++----- src/api/projects/repository/files/create.rs | 11 ++----- src/api/projects/repository/tags/tags.rs | 11 ++----- src/api/users/projects.rs | 11 ++----- src/api/users/users.rs | 11 ++----- 23 files changed, 50 insertions(+), 224 deletions(-) diff --git a/src/api/common.rs b/src/api/common.rs index 6c0a8f6b..9318253e 100644 --- a/src/api/common.rs +++ b/src/api/common.rs @@ -76,22 +76,15 @@ impl AccessLevel { } /// Orderings for sorted results. -#[derive(Debug, Clone, Copy, PartialEq, Eq)] +#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)] pub enum SortOrder { /// Values should be sorted with "higher" values after "lower" values. Ascending, /// Values should be sorted with "lower" values after "higher" values. + #[default] Descending, } -#[allow(clippy::derivable_impls)] -impl Default for SortOrder { - fn default() -> Self { - // XXX(rust-1.62): use `#[default]` - SortOrder::Descending - } -} - impl SortOrder { /// The string representation of the sort order. pub fn as_str(self) -> &'static str { @@ -291,12 +284,13 @@ impl ParamValue<'static> for YesNo { } /// Access levels for protected branches and tags. -#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] +#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] #[non_exhaustive] pub enum ProtectedAccessLevel { /// Developers and maintainers may perform the action. Developer, /// Maintainers may perform the action. + #[default] Maintainer, /// Only administrators may perform the action. Admin, @@ -304,14 +298,6 @@ pub enum ProtectedAccessLevel { NoAccess, } -#[allow(clippy::derivable_impls)] -impl Default for ProtectedAccessLevel { - fn default() -> Self { - // XXX(rust-1.62): use `#[default]` - ProtectedAccessLevel::Maintainer - } -} - impl ProtectedAccessLevel { fn as_str(self) -> &'static str { match self { @@ -330,25 +316,18 @@ impl ParamValue<'static> for ProtectedAccessLevel { } /// Access levels for protected branches and tags. -#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] +#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] #[non_exhaustive] pub enum ProtectedAccessLevelWithAccess { /// Developers and maintainers may perform the action. Developer, /// Maintainers may perform the action. + #[default] Maintainer, /// Only administrators may perform the action. Admin, } -#[allow(clippy::derivable_impls)] -impl Default for ProtectedAccessLevelWithAccess { - fn default() -> Self { - // XXX(rust-1.62): use `#[default]` - ProtectedAccessLevelWithAccess::Maintainer - } -} - impl From for ProtectedAccessLevel { fn from(p: ProtectedAccessLevelWithAccess) -> Self { match p { diff --git a/src/api/groups/groups.rs b/src/api/groups/groups.rs index 55055c3c..20044217 100644 --- a/src/api/groups/groups.rs +++ b/src/api/groups/groups.rs @@ -13,10 +13,11 @@ use crate::api::endpoint_prelude::*; use crate::api::ParamValue; /// Keys group results may be ordered by. -#[derive(Debug, Clone, Copy, PartialEq, Eq)] +#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)] #[non_exhaustive] pub enum GroupOrderBy { /// Order by the name of the group. + #[default] Name, /// Order by the full path of the group. Path, @@ -26,14 +27,6 @@ pub enum GroupOrderBy { Similarity, } -#[allow(clippy::derivable_impls)] -impl Default for GroupOrderBy { - fn default() -> Self { - // XXX(rust-1.62): use `#[default]` - GroupOrderBy::Name - } -} - impl GroupOrderBy { fn use_keyset_pagination(self) -> bool { matches!(self, GroupOrderBy::Name) diff --git a/src/api/groups/projects/projects.rs b/src/api/groups/projects/projects.rs index 0deae8fc..515edc96 100644 --- a/src/api/groups/projects/projects.rs +++ b/src/api/groups/projects/projects.rs @@ -11,7 +11,7 @@ use crate::api::endpoint_prelude::*; use crate::api::ParamValue; /// Keys project results may be ordered by. -#[derive(Debug, Clone, Copy, PartialEq, Eq)] +#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)] #[non_exhaustive] pub enum GroupProjectsOrderBy { /// Order by the user ID. @@ -21,6 +21,7 @@ pub enum GroupProjectsOrderBy { /// Order by the path. Path, /// Order by the creation date of the project. + #[default] CreatedAt, /// Order by the last updated date of the project. UpdatedAt, @@ -30,14 +31,6 @@ pub enum GroupProjectsOrderBy { LastActivityAt, } -#[allow(clippy::derivable_impls)] -impl Default for GroupProjectsOrderBy { - fn default() -> Self { - // XXX(rust-1.62): use `#[default]` - GroupProjectsOrderBy::CreatedAt - } -} - impl GroupProjectsOrderBy { /// The ordering as a query parameter. fn as_str(self) -> &'static str { diff --git a/src/api/groups/projects/shared.rs b/src/api/groups/projects/shared.rs index b48c4c07..aa918223 100644 --- a/src/api/groups/projects/shared.rs +++ b/src/api/groups/projects/shared.rs @@ -11,7 +11,7 @@ use crate::api::endpoint_prelude::*; use crate::api::ParamValue; /// Keys project results may be ordered by. -#[derive(Debug, Clone, Copy, PartialEq, Eq)] +#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)] #[non_exhaustive] pub enum SharedGroupProjectsOrderBy { /// Order by the user ID. @@ -21,6 +21,7 @@ pub enum SharedGroupProjectsOrderBy { /// Order by the path. Path, /// Order by the creation date of the project. + #[default] CreatedAt, /// Order by the last updated date of the project. UpdatedAt, @@ -28,14 +29,6 @@ pub enum SharedGroupProjectsOrderBy { LastActivityAt, } -#[allow(clippy::derivable_impls)] -impl Default for SharedGroupProjectsOrderBy { - fn default() -> Self { - // XXX(rust-1.62): use `#[default]` - SharedGroupProjectsOrderBy::CreatedAt - } -} - impl SharedGroupProjectsOrderBy { /// The ordering as a query parameter. fn as_str(self) -> &'static str { diff --git a/src/api/groups/subgroups/subgroups.rs b/src/api/groups/subgroups/subgroups.rs index 84af79ef..8274e074 100644 --- a/src/api/groups/subgroups/subgroups.rs +++ b/src/api/groups/subgroups/subgroups.rs @@ -13,25 +13,18 @@ use crate::api::endpoint_prelude::*; use crate::api::ParamValue; /// Keys subgroup results may be ordered by. -#[derive(Debug, Clone, Copy, PartialEq, Eq)] +#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)] #[non_exhaustive] pub enum GroupSubgroupsOrderBy { /// Order by the user ID. Id, /// Order by the user display name. + #[default] Name, /// Order by the path. Path, } -#[allow(clippy::derivable_impls)] -impl Default for GroupSubgroupsOrderBy { - fn default() -> Self { - // XXX(rust-1.62): use `#[default]` - GroupSubgroupsOrderBy::Name - } -} - impl GroupSubgroupsOrderBy { /// The ordering as a query parameter. fn as_str(self) -> &'static str { diff --git a/src/api/helpers.rs b/src/api/helpers.rs index b646787d..d8fd3a31 100644 --- a/src/api/helpers.rs +++ b/src/api/helpers.rs @@ -16,23 +16,16 @@ use crate::api::common::CommaSeparatedList; use crate::api::ParamValue; /// Keys note results may be ordered by. -#[derive(Debug, Clone, Copy, PartialEq, Eq)] +#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)] #[non_exhaustive] pub enum NoteOrderBy { /// Sort by creation date. + #[default] CreatedAt, /// Sort by last updated date. UpdatedAt, } -#[allow(clippy::derivable_impls)] -impl Default for NoteOrderBy { - fn default() -> Self { - // XXX(rust-1.62): use `#[default]` - NoteOrderBy::CreatedAt - } -} - impl NoteOrderBy { fn as_str(self) -> &'static str { match self { diff --git a/src/api/issues.rs b/src/api/issues.rs index 20256345..8f98fdd6 100644 --- a/src/api/issues.rs +++ b/src/api/issues.rs @@ -328,10 +328,11 @@ impl ParamValue<'static> for IssueDueDateFilter { } /// Keys issue results may be ordered by. -#[derive(Debug, Clone, Copy, PartialEq, Eq)] +#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)] #[non_exhaustive] pub enum IssueOrderBy { /// Sort by creation date. + #[default] CreatedAt, /// Sort by last updated date. UpdatedAt, @@ -358,14 +359,6 @@ pub enum IssueOrderBy { WeightFields, } -#[allow(clippy::derivable_impls)] -impl Default for IssueOrderBy { - fn default() -> Self { - // XXX(rust-1.62): use `#[default]` - IssueOrderBy::CreatedAt - } -} - impl IssueOrderBy { fn as_str(self) -> &'static str { match self { diff --git a/src/api/merge_requests/merge_request.rs b/src/api/merge_requests/merge_request.rs index 84695f13..be2bc0a0 100644 --- a/src/api/merge_requests/merge_request.rs +++ b/src/api/merge_requests/merge_request.rs @@ -119,10 +119,11 @@ impl<'a, 'b: 'a> ParamValue<'a> for &'b MergeRequestMilestone<'a> { } /// Keys merge request results may be ordered by. -#[derive(Debug, Clone, Copy, PartialEq, Eq)] +#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)] #[non_exhaustive] pub enum MergeRequestOrderBy { /// Sort by creation date. + #[default] CreatedAt, /// Sort by merge date. MergedAt, @@ -132,14 +133,6 @@ pub enum MergeRequestOrderBy { Title, } -#[allow(clippy::derivable_impls)] -impl Default for MergeRequestOrderBy { - fn default() -> Self { - // XXX(rust-1.62): use `#[default]` - MergeRequestOrderBy::CreatedAt - } -} - impl MergeRequestOrderBy { fn as_str(self) -> &'static str { match self { diff --git a/src/api/paged/pagination.rs b/src/api/paged/pagination.rs index ff8e723b..36e9e22f 100644 --- a/src/api/paged/pagination.rs +++ b/src/api/paged/pagination.rs @@ -29,13 +29,14 @@ pub enum PaginationError { } /// Pagination options for GitLab. -#[derive(Debug, Clone, Copy, PartialEq, Eq)] +#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)] #[non_exhaustive] pub enum Pagination { /// Return all results. /// /// Note that some endpoints may have a server-side limit to the number of results (e.g., /// `/projects` is limited to 10000 results). + #[default] All, /// Return all results. /// @@ -46,14 +47,6 @@ pub enum Pagination { Limit(usize), } -#[allow(clippy::derivable_impls)] -impl Default for Pagination { - fn default() -> Self { - // XXX(rust-1.62): use `#[default]` - Pagination::All - } -} - const MAX_PAGE_SIZE: usize = 100; impl Pagination { diff --git a/src/api/projects/create.rs b/src/api/projects/create.rs index eb9eb579..506e0591 100644 --- a/src/api/projects/create.rs +++ b/src/api/projects/create.rs @@ -397,25 +397,18 @@ impl ParamValue<'static> for SquashOption { } /// The default Git strategy for CI jobs. -#[derive(Debug, Clone, Copy, PartialEq, Eq)] +#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)] #[non_exhaustive] pub enum BuildGitStrategy { /// Clone the repository every time. Clone, /// Fetch into an existing checkout (will clone if not available). + #[default] Fetch, /// Do not update the repository at all. None, } -#[allow(clippy::derivable_impls)] -impl Default for BuildGitStrategy { - fn default() -> Self { - // XXX(rust-1.62): use `#[default]` - BuildGitStrategy::Fetch - } -} - impl BuildGitStrategy { /// The variable type query parameter. pub(crate) fn as_str(self) -> &'static str { diff --git a/src/api/projects/packages/generic/upload.rs b/src/api/projects/packages/generic/upload.rs index b36e3218..e4cceca4 100644 --- a/src/api/projects/packages/generic/upload.rs +++ b/src/api/projects/packages/generic/upload.rs @@ -13,23 +13,16 @@ use derive_builder::Builder; /// /// It can be default (default) or hidden. Hidden packages do not appear in the UI or package API /// list endpoints. -#[derive(Debug, Clone, Copy, PartialEq, Eq)] +#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)] #[non_exhaustive] pub enum UploadPackageStatus { /// All packages that appear in the UI + #[default] Default, /// All packages that don't appear in the UI Hidden, } -#[allow(clippy::derivable_impls)] -impl Default for UploadPackageStatus { - fn default() -> Self { - // XXX(rust-1.62): use `#[default]` - UploadPackageStatus::Default - } -} - impl UploadPackageStatus { /// The status as a query parameter fn as_str(self) -> &'static str { diff --git a/src/api/projects/pipelines/create.rs b/src/api/projects/pipelines/create.rs index ed501ed2..e4d4b176 100644 --- a/src/api/projects/pipelines/create.rs +++ b/src/api/projects/pipelines/create.rs @@ -10,12 +10,13 @@ use crate::api::common::NameOrId; use crate::api::endpoint_prelude::*; /// The type of a pipeline variable. -#[derive(Debug, Clone, Copy, PartialEq, Eq)] +#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)] #[non_exhaustive] pub enum PipelineVariableType { /// An environment variable. /// /// The value of the variable is available as the value of the named environment variable. + #[default] EnvVar, /// A file variable. /// @@ -24,14 +25,6 @@ pub enum PipelineVariableType { File, } -#[allow(clippy::derivable_impls)] -impl Default for PipelineVariableType { - fn default() -> Self { - // XXX(rust-1.62): use `#[default]` - PipelineVariableType::EnvVar - } -} - impl PipelineVariableType { /// The variable type query parameter. fn as_str(self) -> &'static str { diff --git a/src/api/projects/pipelines/pipelines.rs b/src/api/projects/pipelines/pipelines.rs index c959b16e..c244f660 100644 --- a/src/api/projects/pipelines/pipelines.rs +++ b/src/api/projects/pipelines/pipelines.rs @@ -100,10 +100,11 @@ impl ParamValue<'static> for PipelineStatus { } /// Keys pipeline results may be ordered by. -#[derive(Debug, Clone, Copy, PartialEq, Eq)] +#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)] #[non_exhaustive] pub enum PipelineOrderBy { /// Order by the pipeline ID. + #[default] Id, /// Order by the status of the pipeline. Status, @@ -115,14 +116,6 @@ pub enum PipelineOrderBy { UserId, } -#[allow(clippy::derivable_impls)] -impl Default for PipelineOrderBy { - fn default() -> Self { - // XXX(rust-1.62): use `#[default]` - PipelineOrderBy::Id - } -} - impl PipelineOrderBy { /// The ordering as a query parameter. fn as_str(self) -> &'static str { diff --git a/src/api/projects/projects.rs b/src/api/projects/projects.rs index 475f809b..e1fcd862 100644 --- a/src/api/projects/projects.rs +++ b/src/api/projects/projects.rs @@ -14,7 +14,7 @@ use crate::api::endpoint_prelude::*; use crate::api::ParamValue; /// Keys project results may be ordered by. -#[derive(Debug, Clone, Copy, PartialEq, Eq)] +#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)] #[non_exhaustive] pub enum ProjectOrderBy { /// Order by the project ID. @@ -24,6 +24,7 @@ pub enum ProjectOrderBy { /// Order by the full path of the project. Path, /// Order by the creation date of the project. + #[default] CreatedAt, /// Order by the last updated date of the project. UpdatedAt, @@ -41,14 +42,6 @@ pub enum ProjectOrderBy { WikiSize, } -#[allow(clippy::derivable_impls)] -impl Default for ProjectOrderBy { - fn default() -> Self { - // XXX(rust-1.62): use `#[default]` - ProjectOrderBy::CreatedAt - } -} - impl ProjectOrderBy { fn use_keyset_pagination(self) -> bool { matches!(self, ProjectOrderBy::Id) diff --git a/src/api/projects/releases/links/common.rs b/src/api/projects/releases/links/common.rs index eb42ebf8..73342fb2 100644 --- a/src/api/projects/releases/links/common.rs +++ b/src/api/projects/releases/links/common.rs @@ -9,10 +9,11 @@ use crate::api::ParamValue; /// The type of the link: other, runbook, image, package. /// /// Defaults to `Other`. -#[derive(Debug, Clone, Copy, PartialEq, Eq)] +#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)] #[non_exhaustive] pub enum LinkType { /// Link to any other file + #[default] Other, /// Link to a runbook file Runbook, @@ -22,14 +23,6 @@ pub enum LinkType { Package, } -#[allow(clippy::derivable_impls)] -impl Default for LinkType { - fn default() -> Self { - // XXX(rust-1.62): use `#[default]` - LinkType::Other - } -} - impl LinkType { pub(in super::super) fn as_str(self) -> &'static str { match self { diff --git a/src/api/projects/releases/releases.rs b/src/api/projects/releases/releases.rs index a0d02462..7fa9d7af 100644 --- a/src/api/projects/releases/releases.rs +++ b/src/api/projects/releases/releases.rs @@ -11,23 +11,16 @@ use crate::api::endpoint_prelude::*; use crate::api::ParamValue; /// Keys group results may be ordered by. -#[derive(Debug, Clone, Copy, PartialEq, Eq)] +#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)] #[non_exhaustive] pub enum ProjectReleaseOrderBy { /// Order by the release date. + #[default] ReleasedAt, /// Order by the creation date. CreatedAt, } -#[allow(clippy::derivable_impls)] -impl Default for ProjectReleaseOrderBy { - fn default() -> Self { - // XXX(rust-1.62): use `#[default]` - ProjectReleaseOrderBy::ReleasedAt - } -} - impl ProjectReleaseOrderBy { /// The ordering as a query parameter. fn as_str(self) -> &'static str { diff --git a/src/api/projects/repository/commits/commits.rs b/src/api/projects/repository/commits/commits.rs index d33b093e..fe226c60 100644 --- a/src/api/projects/repository/commits/commits.rs +++ b/src/api/projects/repository/commits/commits.rs @@ -12,23 +12,16 @@ use crate::api::endpoint_prelude::*; use crate::api::ParamValue; /// Orders commits may be ordered by. -#[derive(Debug, Clone, Copy, PartialEq, Eq)] +#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)] #[non_exhaustive] pub enum CommitsOrder { /// Commits are returned in reverse chronological order. + #[default] Default, /// Commits are returned in topological order. Topo, } -#[allow(clippy::derivable_impls)] -impl Default for CommitsOrder { - fn default() -> Self { - // XXX(rust-1.62): use `#[default]` - CommitsOrder::Default - } -} - impl CommitsOrder { fn as_str(self) -> &'static str { match self { diff --git a/src/api/projects/repository/commits/create.rs b/src/api/projects/repository/commits/create.rs index 049e6d3e..d1e67a73 100644 --- a/src/api/projects/repository/commits/create.rs +++ b/src/api/projects/repository/commits/create.rs @@ -15,11 +15,11 @@ use crate::api::projects::repository::files::Encoding; use crate::api::ParamValue; /// All actions that can be performed in a commit -#[derive(Debug, Clone, Copy, PartialEq, Eq)] +#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)] #[non_exhaustive] pub enum CommitActionType { /// Create a file. - // XXX(rust-1.62): use `#[default]` + #[default] Create, /// delete a file. Delete, @@ -31,12 +31,6 @@ pub enum CommitActionType { Chmod, } -impl Default for CommitActionType { - fn default() -> Self { - Self::Create - } -} - impl CommitActionType { /// The string representation of the visibility level. pub fn as_str(self) -> &'static str { diff --git a/src/api/projects/repository/contributors/contributors.rs b/src/api/projects/repository/contributors/contributors.rs index 24930d46..bc0ce22f 100644 --- a/src/api/projects/repository/contributors/contributors.rs +++ b/src/api/projects/repository/contributors/contributors.rs @@ -7,7 +7,7 @@ use crate::api::endpoint_prelude::*; use crate::api::ParamValue; /// Keys contributor results may be ordered by. -#[derive(Debug, Clone, Copy, PartialEq, Eq)] +#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)] #[non_exhaustive] pub enum ContributorsOrderBy { /// Order by the user name. @@ -15,17 +15,10 @@ pub enum ContributorsOrderBy { /// Order by email. Email, /// Order by most recent commit. + #[default] Commits, } -#[allow(clippy::derivable_impls)] -impl Default for ContributorsOrderBy { - fn default() -> Self { - // XXX(rust-1.62): use `#[default]` - ContributorsOrderBy::Commits - } -} - impl ContributorsOrderBy { /// The ordering as a query parameter. fn as_str(self) -> &'static str { diff --git a/src/api/projects/repository/files/create.rs b/src/api/projects/repository/files/create.rs index cf144cae..d3bc46e8 100644 --- a/src/api/projects/repository/files/create.rs +++ b/src/api/projects/repository/files/create.rs @@ -15,12 +15,13 @@ use crate::api::endpoint_prelude::*; use crate::api::ParamValue; /// Encodings for uploading file contents through an HTTP request. -#[derive(Debug, Clone, Copy, PartialEq, Eq)] +#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)] #[non_exhaustive] pub enum Encoding { /// No special encoding. /// /// Only supports UTF-8 content. + #[default] Text, /// Base64-encoding. /// @@ -28,14 +29,6 @@ pub enum Encoding { Base64, } -#[allow(clippy::derivable_impls)] -impl Default for Encoding { - fn default() -> Self { - // XXX(rust-1.62): use `#[default]` - Encoding::Text - } -} - impl Encoding { pub(crate) fn is_binary_safe(self) -> bool { match self { diff --git a/src/api/projects/repository/tags/tags.rs b/src/api/projects/repository/tags/tags.rs index b4015424..78594b9d 100644 --- a/src/api/projects/repository/tags/tags.rs +++ b/src/api/projects/repository/tags/tags.rs @@ -11,10 +11,11 @@ use crate::api::endpoint_prelude::*; use crate::api::{common::NameOrId, ParamValue}; /// Orders commits may be ordered by. -#[derive(Debug, Clone, Copy, PartialEq, Eq)] +#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)] #[non_exhaustive] pub enum TagsOrderBy { /// Commits are returned in reverse chronological order. + #[default] Name, /// Commits are returned in topological order. Updated, @@ -32,14 +33,6 @@ impl TagsOrderBy { } } -#[allow(clippy::derivable_impls)] -impl Default for TagsOrderBy { - fn default() -> Self { - // XXX(rust-1.62): use `#[default]` - TagsOrderBy::Name - } -} - impl ParamValue<'static> for TagsOrderBy { fn as_value(&self) -> Cow<'static, str> { self.as_str().into() diff --git a/src/api/users/projects.rs b/src/api/users/projects.rs index ad2d16e3..b136c694 100644 --- a/src/api/users/projects.rs +++ b/src/api/users/projects.rs @@ -15,7 +15,7 @@ use crate::api::endpoint_prelude::*; use crate::api::ParamValue; /// Keys project results may be ordered by. -#[derive(Debug, Clone, Copy, PartialEq, Eq)] +#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)] #[non_exhaustive] pub enum UserProjectsOrderBy { /// Order by the user ID. @@ -25,6 +25,7 @@ pub enum UserProjectsOrderBy { /// Order by the path. Path, /// Order by the creation date of the project. + #[default] CreatedAt, /// Order by the last updated date of the project. UpdatedAt, @@ -34,14 +35,6 @@ pub enum UserProjectsOrderBy { LastActivityAt, } -#[allow(clippy::derivable_impls)] -impl Default for UserProjectsOrderBy { - fn default() -> Self { - // XXX(rust-1.62): use `#[default]` - UserProjectsOrderBy::CreatedAt - } -} - impl UserProjectsOrderBy { /// The ordering as a query parameter. fn as_str(self) -> &'static str { diff --git a/src/api/users/users.rs b/src/api/users/users.rs index d76d1998..ad27a537 100644 --- a/src/api/users/users.rs +++ b/src/api/users/users.rs @@ -14,10 +14,11 @@ use crate::api::endpoint_prelude::*; use crate::api::ParamValue; /// Keys user results may be ordered by. -#[derive(Debug, Clone, Copy, PartialEq, Eq)] +#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)] #[non_exhaustive] pub enum UserOrderBy { /// Order by the user ID. + #[default] Id, /// Order by the user display name. Name, @@ -29,14 +30,6 @@ pub enum UserOrderBy { UpdatedAt, } -#[allow(clippy::derivable_impls)] -impl Default for UserOrderBy { - fn default() -> Self { - // XXX(rust-1.62): use `#[default]` - UserOrderBy::Id - } -} - impl UserOrderBy { /// The ordering as a query parameter. fn as_str(self) -> &'static str { -- GitLab