You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Maybe one way to easily map from abbrev strings to a parameter enum variant is that I could try to implement a FromAbbrevStrprocedural derive macro. This macro would implement the FromStr trait. And then I could add #[derive(FromAbbrevStr)] to every enum in gribberish::templates::product::parameters::*. Does that sounds like a good way to go?
For example, calling TemperatureProduct::from_str("TMP") would return TemperatureProduct::Temperature.
The text was updated successfully, but these errors were encountered:
JackKelly
changed the title
Implement a FromAbbrev procedural derive macro?
Implement a FromAbbrevStr procedural derive macro?
Oct 3, 2024
Following on from #41 (comment)
Maybe one way to easily map from
abbrev
strings to aparameter
enum variant is that I could try to implement aFromAbbrevStr
procedural derive macro. This macro would implement theFromStr
trait. And then I could add#[derive(FromAbbrevStr)]
to every enum ingribberish::templates::product::parameters::*
. Does that sounds like a good way to go?For example, calling
TemperatureProduct::from_str("TMP")
would returnTemperatureProduct::Temperature
.The text was updated successfully, but these errors were encountered: