I have a function pointer as part of an enum. I can put it in, but I can't seem to figure out how to extract it back out.
Basically, I'd like to know what to put as ZZZ to make Rust quit complaining. I figure something null() with a cast, but this is all no_std so I'm not sure where that would be.
Alternatively, if there is a better way to do what I want, I'm open to that too.
Thanks.
enum EN {
IG,
PTR{fp: fn (ll: i32, rr:i32) -> i32},
}
fn foo(ll: i32, rr: i32) -> i32 {
ll+rr
}
fn matchme(qq: EN) {
let bb: fn (ll: i32, rr:i32) -> i32 = match qq {
EN::PTR{fp: matched_fp} => matched_fp,
_ => ZZZ,
};
println!("fp: {:?}", bb);
}
fn main() {
let aa = EN::PTR{fp: foo};
matchme(aa);
}
Errors:
Compiling playground v0.0.1 (/playground)
error[E0425]: cannot find value `ZZZ` in this scope
--> src/main.rs:15:14
|
15 | _ => ZZZ,
| ^^^ not found in this scope
For more information about this error, try `rustc --explain E0425`.
error: could not compile `playground` due to previous error