I'm trying to access the version of a particular clap::App
I have instantiated. However, the field version
exists as does the public function version()
Here is the relevant bits of source code:
pub struct App<'a, 'v, 'ab, 'u, 'h, 'ar> {
// ...
version: Option<&'v str>,
// ...
}
impl<'a, 'v, 'ab, 'u, 'h, 'ar> App<'a, 'v, 'ab, 'u, 'h, 'ar>{
// ...
pub fn version(mut self, v: &'v str) -> Self {
self.version = Some(v);
self
}
// ...
}
And my code:
pub fn build_cli() -> App<'static, 'static> {
App::new("my-pi")
.version("0.1.0")
// ...
let app = build_cli();
assert_eq!(app.version, "0.1.0"); // <-- Error here
The field version
and function version()
both exist on App
. How can this be? And how can I access the field version
?
The error:
error[E0615]: attempted to take value of method `version` on type `clap::App<'_, '_>`
--> src/cli.rs:27:21
|
27 | assert_eq!(app.version, "0.1.0");
| ^^^^^^^
|
= help: maybe a `()` to call it is missing?