cue/ast: add walkNilable and applyNilable helpers
To avoid the repetition of explicit nil checks.
Overall we don't save that many lines of code, but what matters
is that saving repetition reduces the chances for human mistakes,
like using different fields for the nil check and the recursing call.
Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
Change-Id: Ic1aacaf86bc3a7f1d93948e1c1709334c1f2fadf
Reviewed-on: https://cue.gerrithub.io/c/cue-lang/cue/+/1227720
Reviewed-by: Roger Peppe <rogpeppe@gmail.com>
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>