Crisis averted! Managed to write a simple macro after some help and inspiration from @dzamlo that does what I want it to. Thanks for all the suggestions and help!pic.twitter.com/vFe3aluM0a
You can add location information to your Tweets, such as your city or precise location, from the web and via third-party applications. You always have the option to delete your Tweet location history. Learn more
Crisis averted! Managed to write a simple macro after some help and inspiration from @dzamlo that does what I want it to. Thanks for all the suggestions and help!pic.twitter.com/vFe3aluM0a
One option to move the redundant code to a generic trait implemented on the Enum: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=cb15b5610e1ceee2f151eb05d427e79e … But this doesn't help much. Another option is to use a macro: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=1c6c55c410fe86d6d4dcc73b0cda0908 … I'm not sure this a better way.
Thanks for your help! I haven't written any macros before so your example was of great help (and inspiration). After some thought I managed to get something working:pic.twitter.com/5DDsh0bsyQ
Maybe a marker trait for these struct plus an generic function ?
Problem is that "CollectorConfiguration" is an enum. Not sure how I can make this generic
I have never ever used rust but looking at it I wonder if you could not switch it completely backwards and iterate over the configurations instead of the enum?
That’s bot possible. I need to match on the enums to access the configs
You could make it generic over the type of config? Though for a test it might be overkill
i don't think there's a way. i've wished there were a good solution for going from `pattern that binds a value` => `option containing that value` (for any enum/pattern). I can't think of what that would look like though, or I'd consider RFCing it...
Ah, that said, if you write function like `CollectorConfiguration::as_azure(&self) -> Option<&AzureDevopsConfiguration>` then these could be shaped like `self.iter().find_map(|c| http://c.as _azure()).expect("unable to find ...")`. Might be better.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.