From cf94bdc0742c13e2a0cac864c478b8626b266e1b Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:11:38 +0200 Subject: Merging upstream version 1.66.0+dfsg1. Signed-off-by: Daniel Baumann --- vendor/clap/examples/typed-derive.rs | 44 ------------------------------------ 1 file changed, 44 deletions(-) delete mode 100644 vendor/clap/examples/typed-derive.rs (limited to 'vendor/clap/examples/typed-derive.rs') diff --git a/vendor/clap/examples/typed-derive.rs b/vendor/clap/examples/typed-derive.rs deleted file mode 100644 index 31084029d..000000000 --- a/vendor/clap/examples/typed-derive.rs +++ /dev/null @@ -1,44 +0,0 @@ -use clap::Parser; -use std::error::Error; - -#[derive(Parser, Debug)] // requires `derive` feature -struct Args { - /// Implicitly using `std::str::FromStr` - #[clap(short = 'O', value_parser)] - optimization: Option, - - /// Allow invalid UTF-8 paths - #[clap(short = 'I', value_parser, value_name = "DIR", value_hint = clap::ValueHint::DirPath)] - include: Option, - - /// Handle IP addresses - #[clap(long, value_parser)] - bind: Option, - - /// Allow human-readable durations - #[clap(long, value_parser)] - sleep: Option, - - /// Hand-written parser for tuples - #[clap(short = 'D', value_parser = parse_key_val::)] - defines: Vec<(String, i32)>, -} - -/// Parse a single key-value pair -fn parse_key_val(s: &str) -> Result<(T, U), Box> -where - T: std::str::FromStr, - T::Err: Error + Send + Sync + 'static, - U: std::str::FromStr, - U::Err: Error + Send + Sync + 'static, -{ - let pos = s - .find('=') - .ok_or_else(|| format!("invalid KEY=value: no `=` found in `{}`", s))?; - Ok((s[..pos].parse()?, s[pos + 1..].parse()?)) -} - -fn main() { - let args = Args::parse(); - println!("{:?}", args); -} -- cgit v1.2.3