]> git.proxmox.com Git - rustc.git/blobdiff - vendor/clap/examples/tutorial_builder/05_01_assert.rs
New upstream version 1.63.0+dfsg1
[rustc.git] / vendor / clap / examples / tutorial_builder / 05_01_assert.rs
index 26f073b6775b5790537cb694b3d1440f96985c44..d6f19ffe538777e20e4779d8b982fa3a16830fe5 100644 (file)
@@ -1,11 +1,13 @@
-use clap::{arg, command};
+// Note: this requires the `cargo` feature
+
+use clap::{arg, command, value_parser};
 
 fn main() {
     let matches = cmd().get_matches();
 
     // Note, it's safe to call unwrap() because the arg is required
-    let port: usize = matches
-        .value_of_t("PORT")
+    let port: usize = *matches
+        .get_one::<usize>("PORT")
         .expect("'PORT' is required and parsing will fail if its missing");
     println!("PORT = {}", port);
 }
@@ -14,7 +16,7 @@ fn cmd() -> clap::Command<'static> {
     command!().arg(
         arg!(<PORT>)
             .help("Network port to use")
-            .validator(|s| s.parse::<usize>()),
+            .value_parser(value_parser!(usize)),
     )
 }