diff --git a/src/api/common.rs b/src/api/common.rs index 6c0a8f6b1e916ff11081e1ef40da960937700577..9318253e5007a2d6ba10458d5cd04acc570904ea 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 55055c3c64d5c7e8e0008e6b4f58f5433d65109f..20044217fbb2f31ce533392635649b7e1f01490c 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 0deae8fcfb38d0a9d94a85e9caac53a6e1f728e2..515edc96aac58c00c65b852f459e18374aedb205 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 b48c4c07cf0b7a7017d6c986f96e4c44884ad760..aa918223fc0ddbd0c2a13253bbf949a187cb3b94 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 84af79efff99d4abfec34f026d633fddf2ed552b..8274e074a11c33efce96f41dc798e532b5e0acf3 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 b646787d8dccda468660cae6907a6d013b1464ce..d8fd3a31ebec50a497a9ac355a462dc34b6e9a00 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 20256345cae24fc136cd9ec1bb8b2e4426a2dcd9..8f98fdd6131c5a6bd1a6bb710e5dce7866278f99 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 84695f135da09344a6f088c47fd2df7d52540250..be2bc0a0762784d52d662492ea4de72a6abf00b8 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 ff8e723bb309124513e4c81fa780f34c21b8cdf7..36e9e22f3e3a14edce0cca2c7eff35b4576aab7c 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 eb9eb579b8a537ed5b48b488d946b648e7c8eaf7..506e05918d421a1895a8a902a8a0e7abb5b683bd 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 b36e32181227322162c2677146d70c2e8281430c..e4cceca4a36ef7105c6fcd5cb13d19527a0582ed 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 ed501ed2ebcdba0a9bd615861e429344e9afbfcf..e4d4b1769b740f582be7aa7293ab62d69a0dd907 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 c959b16eb175d9196df789d34ad3ff66d0697f90..c244f660920b54e64e87762621e3d5944c4a05ff 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 475f809b1dfa879d8f90de51073f8efe57ac6f6a..e1fcd862f99e24560e08ebb095abfdc7c81deb85 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 eb42ebf88329a836c91f524e68bd036f70d89f99..73342fb21ef0670ff97716b6497febac3353b466 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 a0d02462b6ed47b5d6b4af29ad4aac49251afe7b..7fa9d7af601209bbee6ce1a1d9640ccedd49e0f7 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 d33b093ed56f36ddeea49a733acfa744103433d0..fe226c60556fc02ae482f6b5612ad4a34e2e33c3 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 049e6d3e8f66ddba0444ba031e9496c8a53a54ca..d1e67a7323c5f46a0a877d588294160d1f572e91 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 24930d4609a05f2f053b4bfcb858094184de0247..bc0ce22f94627ee69eba752be274afa268bd362c 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 cf144caed1d4d6e6c6654631442a2f83e5a6bfea..d3bc46e8b9dc4abd369ccf7fed057399cd93d036 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 b40154241409f770e2dd50d7ce155b3c6ed817c6..78594b9d51c0c898f57c23f49422c017777ee5b0 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 ad2d16e3833337f21223772f291817dc6ee59f94..b136c694c23801509fe300d49a16c93aabbeac39 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 d76d199859d60398d0e761673fd9ac9ac6e0e222..ad27a53780f54b460b9ecebb6478dd4a0f5b8ec9 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 {