macro_rules! with_nested {
($field:expr, $type:ty, $var:ident => $body:block) => { ... };
}Expand description
Macro to handle optional nested config initialization in builders.
This macro eliminates the repeated pattern of:
// if self.config.field.is_none() {
// self.config.field = Some(Type::new());
// }ยงUsage
// Instead of:
// if self.config.orientation.is_none() {
// self.config.orientation = Some(DocOrientationClassifierConfig::new());
// }
// if let Some(ref mut config) = self.config.orientation {
// config.confidence_threshold = Some(threshold);
// }
// Use:
// with_nested!(self.config.orientation, DocOrientationClassifierConfig, config => {
// config.confidence_threshold = Some(threshold);
// });