I'm trying to store clap::ArgMatches
in a struct like so:
struct Configurator {
cli_args: ArgMatches,
root_directory: String
}
The error I receive is:
error[E0106]: missing lifetime specifier
--> src/configurator.rs:5:15
|
5 | cli_args: ArgMatches,
| ^^^^^^^^^^ expected named lifetime parameter
|
help: consider introducing a named lifetime parameter
|
4 | struct Configurator<'a> {
5 | cli_args: ArgMatches<'a>,
|
I tried the suggested solution that is given in the error output, but that appears to cause different errors.
Here's a little more context:
extern crate clap;
use clap::{Arg, App, ArgMatches};
struct Configurator {
cli_args: ArgMatches,
root_directory: String
}
impl Configurator {
pub fn build() -> Configurator {
let configurator = Configurator {};
// returns ArgMatches apparently
let cli_args = App::new("Rust Web Server")
.version("0.0.1")
.author("Blaine Lafreniere <brlafreniere@gmail.com>")
.about("A simple web server built in rust.")
.arg(Arg::with_name("root_dir")
.short("r")
.long("root_dir")
.value_name("ROOT_DIR")
.help("Set the root directory that the web server will serve from.")
.takes_value(true))
.get_matches();
configurator.cli_args = cli_args;
}
}