cxx
cxx copied to clipboard
Workaround for enums with variant data?
Is there a workaround for APIs that want to return an enum with variant data (or std::variant
; #217)? The best I can think of at the moment is:
pub struct Info {
pub variant_a Option<Box<VariantAData>>,
pub variant_b: Option<Box<VariantBData>>,
// ...
}
fn get_info() -> Info;
But that's not exactly elegant, plus it relies on heap allocation to avoid making Info
huge. Is there a better way?