Hi all,
I'm a hobbyist that is slowly going through the proc macro workshop, just for fun.
I have the first handful of tests on the Builder
project working, but I keep running into a pattern that makes me think that there is a more idiomatic alternative that I'm missing: setting an Optional<T>
with layers of match
and if let
that result in layers and layers of else { None }
.
For example. (or the most recent version, with else { Ok(None) }
repeated instead.)
It seems that if trying to match target == 42
that is embedded several layers deep in some struct with mixed Optionals and sequences etc. on the way down that there is probably a better way to do several matches without having to keep saying else { None }
for every alternative path. Right?
I keep thinking that there is probably some way to .map
or .and_then
my way to a cleaner approach, but the sequences and match guards seem to keep interfering with chaining them, and AFAICT there's no way around that.
TIA for any suggestions!