From be73195ecfe8a082783765f87036ce9ecf1ce7c8 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Mon, 25 Mar 2024 14:08:51 -0500 Subject: [PATCH] refactor(derive): Clarify tests --- tests/derive/non_literal_attributes.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/tests/derive/non_literal_attributes.rs b/tests/derive/non_literal_attributes.rs index 63a1d0254c4..25ae36e034c 100644 --- a/tests/derive/non_literal_attributes.rs +++ b/tests/derive/non_literal_attributes.rs @@ -125,19 +125,19 @@ fn test_bool() { assert_eq!(result.unwrap_err().kind(), ErrorKind::NoEquals); } -fn parse_hex(input: &str) -> Result { - u64::from_str_radix(input, 16) -} - -#[derive(Parser, PartialEq, Debug)] -struct HexOpt { - #[arg(short, value_parser = parse_hex)] - number: u64, -} - #[test] #[cfg(feature = "error-context")] fn test_parse_hex_function_path() { + #[derive(Parser, PartialEq, Debug)] + struct HexOpt { + #[arg(short, value_parser = parse_hex)] + number: u64, + } + + fn parse_hex(input: &str) -> Result { + u64::from_str_radix(input, 16) + } + assert_eq!( HexOpt { number: 5 }, HexOpt::try_parse_from(["test", "-n", "5"]).unwrap()