Hello all,
I still do not understand why the following code does not compile:
lazy_static! {
static ref PV: Vec<&'static str> = vec!["abc", "def"];
}
#[derive(StructOpt)]
pub struct CustomArg {
#[structopt(name = "mode", possible_values = "&PV")]
mode: String,
}
the compiler complains:
error[E0308]: mismatched types
--> src\main.rs:76:10
|
76 | #[derive(StructOpt)]
| ^^^^^^^^^ expected slice, found str
|
= note: expected type `&[&str]`
found type `&'static str`
Looking around, I found a similar issue with a suggestion that possible_values should be replaced by possible_values_raw. But when I use possible_values_raw, the compiler complains:
error[E0599]: no method named `possible_values_raw` found for type `structopt::clap::Arg<'_, '_>` in the current scope
--> src\main.rs:76:10
|
76 | #[derive(StructOpt)]
| ^^^^^^^^^
|
= help: did you mean `possible_values`?
Many thanks for any response.
Thats now raw(possible_values = "&PV")
Many thanks @TeXitoi . It compiles now.
Most helpful comment
Thats now
raw(possible_values = "&PV")