From 1260975b2a73e6fed4c660a244e08ec831652f88 Mon Sep 17 00:00:00 2001 From: Aleksander Zdunek Date: Fri, 26 May 2023 18:10:46 +0200 Subject: [PATCH 1/2] Make u16_parse_hex() public Silence dead code warning when building lib with --no-default-features. --- src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 8da614d..ef26115 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -45,7 +45,7 @@ pub struct Filter { pub serial: Option, } -fn u16_parse_hex(s: &str) -> Result { +pub fn u16_parse_hex(s: &str) -> Result { u16::from_str_radix(s, 16) } From 8889b6da05871fb1603529f24213298c444b3a5a Mon Sep 17 00:00:00 2001 From: Aleksander Zdunek Date: Fri, 9 Jun 2023 15:58:17 +0200 Subject: [PATCH 2/2] Document u16_parse_hex() --- src/lib.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index ef26115..baf5918 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -45,6 +45,15 @@ pub struct Filter { pub serial: Option, } +/// Parse hexadecimal formatted string to integer +/// +/// Helper function for parsing PID and VID command line arguments. +/// +/// #Example +/// ``` +/// #[structopt(parse(try_from_str=streamdeck::u16_parse_hex))] +/// pid: u16, +/// ``` pub fn u16_parse_hex(s: &str) -> Result { u16::from_str_radix(s, 16) }