removes manual implementations of Default for enums (#29779)

This commit is contained in:
behzad nouri 2023-01-19 19:25:30 +00:00 committed by GitHub
parent 2c347ac0a5
commit d463bcc5f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 21 deletions

View File

@ -84,17 +84,12 @@ pub const DEFAULT_MAX_INCREMENTAL_SNAPSHOT_ARCHIVES_TO_RETAIN: usize = 4;
pub const FULL_SNAPSHOT_ARCHIVE_FILENAME_REGEX: &str = r"^snapshot-(?P<slot>[[:digit:]]+)-(?P<hash>[[:alnum:]]+)\.(?P<ext>tar|tar\.bz2|tar\.zst|tar\.gz|tar\.lz4)$";
pub const INCREMENTAL_SNAPSHOT_ARCHIVE_FILENAME_REGEX: &str = r"^incremental-snapshot-(?P<base>[[:digit:]]+)-(?P<slot>[[:digit:]]+)-(?P<hash>[[:alnum:]]+)\.(?P<ext>tar|tar\.bz2|tar\.zst|tar\.gz|tar\.lz4)$";
#[derive(Copy, Clone, Eq, PartialEq, Debug)]
#[derive(Copy, Clone, Default, Eq, PartialEq, Debug)]
pub enum SnapshotVersion {
#[default]
V1_2_0,
}
impl Default for SnapshotVersion {
fn default() -> Self {
SnapshotVersion::V1_2_0
}
}
impl fmt::Display for SnapshotVersion {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str(From::from(*self))

View File

@ -67,18 +67,13 @@ impl DurableNonce {
///
/// When created in memory with [`State::default`] or when deserialized from an
/// uninitialized account, a nonce account will be [`State::Uninitialized`].
#[derive(Debug, Serialize, Deserialize, PartialEq, Eq, Clone)]
#[derive(Debug, Default, Serialize, Deserialize, PartialEq, Eq, Clone)]
pub enum State {
#[default]
Uninitialized,
Initialized(Data),
}
impl Default for State {
fn default() -> Self {
State::Uninitialized
}
}
impl State {
/// Create new durable transaction nonce state.
pub fn new_initialized(

View File

@ -16,9 +16,10 @@ use {
pub type StakeActivationStatus = StakeHistoryEntry;
#[derive(Debug, Serialize, Deserialize, PartialEq, Clone, Copy, AbiExample)]
#[derive(Debug, Default, Serialize, Deserialize, PartialEq, Clone, Copy, AbiExample)]
#[allow(clippy::large_enum_variant)]
pub enum StakeState {
#[default]
Uninitialized,
Initialized(Meta),
Stake(Meta, Stake),
@ -66,12 +67,6 @@ impl BorshSerialize for StakeState {
}
}
impl Default for StakeState {
fn default() -> Self {
StakeState::Uninitialized
}
}
impl StakeState {
/// The fixed number of bytes used to serialize each stake account
pub const fn size_of() -> usize {