Implement Default for all bitflags with a DEFAULT
More idomatic Rust pattern would be to use the Default trait, used
only when there is a const named DEFAULT.
Consider making NONE default for bitflags which have a NONE const
but no DEFAULT.
@@ -432,6 +432,12 @@ impl CredentialType {
is_bit_set!(is_username, CredentialType::USERNAME);
}
+impl Default for CredentialType {
+ fn default() -> Self {
+ CredentialType::DEFAULT
+ }
+}
+
bitflags! {
/// Flags for the `flags` field of an IndexEntry.
pub struct IndexEntryFlag: u16 {
@@ -520,6 +526,12 @@ impl IndexAddOption {
is_bit_set!(is_check_pathspec, IndexAddOption::CHECK_PATHSPEC);
}
+impl Default for IndexAddOption {
+ fn default() -> Self {
+ IndexAddOption::DEFAULT
+ }
+}
+
bitflags! {
/// Flags for `Repository::open_ext`
pub struct RepositoryOpenFlags: u32 {
@@ -1145,6 +1157,12 @@ impl PathspecFlags {
is_bit_set!(is_failures_only, PathspecFlags::FAILURES_ONLY);
}
+impl Default for PathspecFlags {
+ fn default() -> Self {
+ PathspecFlags::DEFAULT
+ }
+}
+
bitflags! {
/// Types of notifications emitted from checkouts.
pub struct CheckoutNotificationType: u32 {
@@ -1268,6 +1286,12 @@ impl StashApplyFlags {
is_bit_set!(is_reinstate_index, StashApplyFlags::REINSTATE_INDEX);
}
+impl Default for StashApplyFlags {
+ fn default() -> Self {
+ StashApplyFlags::DEFAULT
+ }
+}
+
bitflags! {
#[allow(missing_docs)]
pub struct StashFlags: u32 {
@@ -1292,6 +1316,12 @@ impl StashFlags {
is_bit_set!(is_include_ignored, StashFlags::INCLUDE_IGNORED);
}
+impl Default for StashFlags {
+ fn default() -> Self {
+ StashFlags::DEFAULT
+ }
+}
+
#[cfg(test)]
mod tests {
use super::ObjectType;
