From 66b4ed1ed928ae19009ad038598ac1e0120dfc2c Mon Sep 17 00:00:00 2001 From: Schuyler Cebulskie Date: Sun, 3 Mar 2024 14:34:34 -0500 Subject: [PATCH] Accept non-lowercase input to FromStr --- src/parse.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/parse.rs b/src/parse.rs index 0f0f363..5705d45 100644 --- a/src/parse.rs +++ b/src/parse.rs @@ -173,9 +173,11 @@ impl std::str::FromStr for Dice { type Err = Error; fn from_str(s: &str) -> Result { - dice().parse(s).into_result().map_err(|errs| Error { + let lc = s.to_lowercase(); + let result = dice().parse(&lc).into_result().map_err(|errs| Error { details: errs.iter().map(|err| err.to_string()).collect::>().join("; "), - }) + }); + result } } @@ -183,8 +185,10 @@ impl std::str::FromStr for Term { type Err = Error; fn from_str(s: &str) -> Result { - term().parse(s).into_result().map_err(|errs| Error { + let lc = s.to_lowercase(); + let result = term().parse(&lc).into_result().map_err(|errs| Error { details: errs.iter().map(|err| err.to_string()).collect::>().join("; "), - }) + }); + result } }