Rust 썸네일형 리스트형 Hex to Decimal use regex::Regex; use crate::error::error::ExpectedError; pub fn hex_to_decimal(hex_str: &str) -> Result { let regex = Regex::new(r"^(0[xX])?[A-Fa-f0-9]+$").unwrap(); match regex.is_match(hex_str) { true => { let prefix_removed = hex_str.trim_start_matches("0x"); match primitive_types::U256::from_str_radix(prefix_removed, 16) { Ok(decimal_u256) => Ok(decimal_u256.to_string()), Err(err) => Err(Ex.. Rust Enumeration Macro pub trait Enumeration { fn value(&self) -> String; fn find(name: &str) -> Option where Self: Sized; fn valid(value: &str) -> bool; } #[macro_export] macro_rules! enumeration { ($enum:ident; $({$types:ident: $values:expr}),*) => { #[derive(Debug, PartialEq, Eq, Clone)] pub enum $enum { $($types,)* } impl Enumeration for $enum { fn value(&self) -> String { match self { $($enum::$types => String::f.. 이전 1 다음