I’m getting a returns a value referencing data owned by the current function
on line 17 on .unwrap_or("/tmp/")
. This is the first time I try something on rust after finishing the book. I still don’t know enough to debug this.
use clap::{Arg, Command};
fn main() {
args = parse_args();
println!("The directory passed is: {}", args[0]);
}
fn parse_args() -> Vec<&str> {
let matches = Command::new("Parse Torrent")
.arg(Arg::new("dir")
.short('f')
.long("dir")
.takes_value(true)
.help("input directory of your computer, example /disk1/dir1/"))
.get_matches();
matches.value_of(dir).unwrap_or("/tmp/")
}
Ask specific questions about how to code something in rust
General rust discussion on lemmy.ml
Create Post From:
lemmy.ml