Closed thorlucas closed 3 years ago
The option inspectable can be configured using the OptionAttributes which have a replacement
field.
You can do
#[derive(Inspectable)]
struct Data {
#[inspectable(replacement = option_replacement as fn() -> f32)]
option: Option<f32>,
#[inspectable(replacement = String::default as fn() -> String)]
option2: Option<String>,
}
fn option_replacement() -> f32 {
0.0
}
(the as fn() -> _
is because of some rustc type inference quirk)
I somehow missed this in the demo. Thanks!
It seems that, while we can revert an
Option<T>
back toNone
, there is no way to convert it back toSome(...)
.Perhaps
Option<T>
should be handled by a checkbox (indicatingNone
when off, andSome
when on), and a textbox that appears to the right of it when on.