Skip to content

Commit

Permalink
Derive default for enums using attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
aewag committed Sep 1, 2024
1 parent d407a3c commit d951ed7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 14 deletions.
9 changes: 2 additions & 7 deletions src/lm_ots/parameters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,16 @@ use crate::{
use crate::util::coef::coef_helper;

/// Specifies the used Winternitz parameter.
#[derive(Clone, Copy, PartialEq, Eq)]
#[derive(Default, Clone, Copy, PartialEq, Eq)]
pub enum LmotsAlgorithm {
#[default]
LmotsReserved = 0,
LmotsW1 = 1,
LmotsW2 = 2,
LmotsW4 = 3,
LmotsW8 = 4,
}

impl Default for LmotsAlgorithm {
fn default() -> Self {
LmotsAlgorithm::LmotsReserved
}
}

impl From<u32> for LmotsAlgorithm {
fn from(_type: u32) -> Self {
match _type {
Expand Down
9 changes: 2 additions & 7 deletions src/lms/parameters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ use core::marker::PhantomData;
use crate::hasher::{sha256::Sha256_256, HashChain};

/// Specifies the used Tree height.
#[derive(Clone, Copy)]
#[derive(Default, Clone, Copy)]
pub enum LmsAlgorithm {
#[default]
LmsReserved = 0,
#[cfg(test)]
LmsH2 = 1,
Expand All @@ -15,12 +16,6 @@ pub enum LmsAlgorithm {
LmsH25 = 9,
}

impl Default for LmsAlgorithm {
fn default() -> Self {
LmsAlgorithm::LmsReserved
}
}

impl From<u32> for LmsAlgorithm {
fn from(_type: u32) -> Self {
match _type {
Expand Down

0 comments on commit d951ed7

Please sign in to comment.