I have used clap crate to parsing arguments in my code. Minimal structure of my code about defining and parsing arguments are as follow.
use clap::builder::Command;
use clap::{Arg, ArgMatches};
let matches = Command::new("test")
.arg(Arg::new("mass")
.short('m')
.takes_value(true))
.get_matches()
let mass: f64 = *matches.get_one::<f64>("mass").unwrap();
But I face an error "thread 'main' panicked at 'Mismatch between definition and access of mass
. Could not downcast to f64, need to downcast to alloc::string::String"
I can fix it by using parse() from String to f64.
let mass: f64 = *matches.get_one::<String>("mass").unwrap().parse().unwrap();
I want to know that why only f64 cannot be parsed by get_one function differ from the case of boolean or usize.