With this code:
#[derive(Parser, Debug)]
#[command(author, version, about, long_about = None)]
struct Args {
#[arg(short, long, default_value_t = ("/dev/ttyUSB3".to_string()))]
modem_path: String,
...
}
I get a warning:
warning: unnecessary parentheses around assigned value
--> src/main.rs:30:42
|
30 | #[arg(short, long, default_value_t = ("/dev/ttyUSB3".to_string()))]
| ^ ^
|
= note: `#[warn(unused_parens)]` on by default
help: remove these parentheses
|
30 - #[arg(short, long, default_value_t = ("/dev/ttyUSB3".to_string()))]
30 + #[arg(short, long, default_value_t = "/dev/ttyUSB3".to_string())]
|
If I remove the parens, I get an error:
error: expected `,`
--> src/main.rs:30:56
|
30 | #[arg(short, long, default_value_t = "/dev/ttyUSB3".to_string())]
| ^
I have many other more complex arguments with the same issue, e.g.
#[arg(short, long, default_value_t = ("127.0.0.1:2947".parse().unwrap()))]
gpsd_socket: SocketAddr,
How can I make this code error- and warning-free?