Add from_string method to BDateFreq enum for easier conversion from String

This commit is contained in:
Palash Tyagi 2025-04-13 00:04:54 +01:00
parent 328fb24509
commit 8343e93b46

View File

@ -71,6 +71,10 @@ pub enum BDateFreq {
} }
impl BDateFreq { impl BDateFreq {
pub fn from_string(freq: String) -> Result<Self, Box<dyn Error>> {
// use `from_str` to convert the string to a BDateFreq enum
Self::from_str(&freq)
}
pub fn from_str(freq: &str) -> Result<Self, Box<dyn Error>> { pub fn from_str(freq: &str) -> Result<Self, Box<dyn Error>> {
match freq { match freq {
"D" => Ok(BDateFreq::Daily), "D" => Ok(BDateFreq::Daily),