From 210082ea4ed38aa9b8f1f739ca5a597ae2586b3e Mon Sep 17 00:00:00 2001 From: Bastian Bloessl Date: Wed, 31 Jul 2024 09:25:48 +0200 Subject: [PATCH] args: impl TryInto for Option --- src/args.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/args.rs b/src/args.rs index 4f83a00..38e50b4 100644 --- a/src/args.rs +++ b/src/args.rs @@ -166,6 +166,17 @@ impl TryInto for &String { } } +impl TryInto for Option { + type Error = Error; + + fn try_into(self) -> Result { + match self { + Some(s) => s.parse(), + None => Ok(Args::new()), + } + } +} + impl From<&Args> for Args { fn from(value: &Args) -> Self { value.clone()