Closed
Description
I spent {way too much} time on this yesterday:
extern crate clap;
fn main() {
let v = "0.1".to_string();
let app = clap::App::new("hello world").version(v);
}
this code fails to build with
error[E0277]: the trait bound `&str: std::convert::From<std::string::String>` is not satisfied
--> src/main.rs:4:45
|
4 | let app = clap::App::new("hello world").version(v);
| ^^^^^^^ the trait `std::convert::From<std::string::String>` is not implemented for `&str`
|
= note: required because of the requirements on the impl of `std::convert::Into<&str>` for `std::string::String`
error: aborting due to previous error
passing v
by reference doesn't help either ( .version(&v)
, the msg is almost identical then).
What fixed this for me in the end was .version(&*v)
.
Is there a way we could suggest to the user to use &*
in this example?
the version
method signature can be found here