lighthouse/testing/ef_tests/src/bls_setting.rs
Akihito Nakano 98a9626ef5 Bump the MSRV to 1.62 and using #[derive(Default)] on enums (#3304)
## Issue Addressed

N/A

## Proposed Changes

Since Rust 1.62, we can use `#[derive(Default)]` on enums.  

https://blog.rust-lang.org/2022/06/30/Rust-1.62.0.html#default-enum-variants

There are no changes to functionality in this PR, just replaced the `Default` trait implementation with `#[derive(Default)]`.
2022-07-15 07:31:19 +00:00

25 lines
648 B
Rust

use self::BlsSetting::*;
use crate::error::Error;
use serde_repr::Deserialize_repr;
#[derive(Deserialize_repr, Debug, Clone, Copy, Default)]
#[repr(u8)]
pub enum BlsSetting {
#[default]
Flexible = 0,
Required = 1,
Ignored = 2,
}
impl BlsSetting {
/// Check the BLS setting and skip the test if it isn't compatible with the crypto config.
pub fn check(self) -> Result<(), Error> {
match self {
Flexible => Ok(()),
Required if !cfg!(feature = "fake_crypto") => Ok(()),
Ignored if cfg!(feature = "fake_crypto") => Ok(()),
_ => Err(Error::SkippedBls),
}
}
}