Still not working full-time with Rust... so likely have forgotten something in the book.
Nonetheless, I am curious about whether I can say the compiler 'eliminates' the variable foo
when feature fooable
is inactive/unset, and is this the/a Rusty-way to avoid calling Some::foo()
more than once:
fun fooable() {
let foo: Option<_>;
if cfg!(feature = "fooable") {
foo = Some(Some::foo());
} else {
foo = None;
}
#[cfg(feature = "fooable")]
{
let b = Some::bar(&foo);
// etc.
}
//more etc.
#[cfg(feature = "fooable")]
{
let b = Some::bar(&foo);
// etc.
}
}