I'm still learning Rust and have just started working with Protobuf definitions via Prost. The definitions are pre-existing (used in a number of projects already) so I can't alter those; I'm looking for help with better / more ideomatic Rust syntax for consuming the structures Prost generates.
In particular, here's a simplification of one scenario I'm dealing with:
#[derive(Default)]
pub struct A {
id: Option<i64>,
}
#[derive(Default)]
pub struct B {
parent: Option<A>,
}
#[derive(Default)]
pub struct C {
parent: Option<B>,
foo: Option<bool>,
}
...
let c = C {
foo: Some(true),
..Default::default()
}
if let Some(b) = c.parent {
if let Some(a) = b.parent {
a.id = Some(999);
}
}
In initializing c, can I:
simplify Some(true) (i.e. some sort of auto-boxing?)
specify grandparent id either:
a) directly in the struct initializer?
b) by some terser syntax than the nested if let ... sequence?