From 2fe98e55188dc2dda4170d5a25551f6c72170e8c Mon Sep 17 00:00:00 2001 From: pml68 Date: Thu, 27 Feb 2025 09:21:13 +0100 Subject: feat: implement `Value` for `Length` --- src/values/rotation.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/values/rotation.rs') diff --git a/src/values/rotation.rs b/src/values/rotation.rs index da291b2..2b609d3 100644 --- a/src/values/rotation.rs +++ b/src/values/rotation.rs @@ -25,6 +25,8 @@ impl Value for Rotation { type Err = ParseRotationError; fn from_str(s: &str) -> Result { + let s = s.trim(); + if s.is_empty() { return Err(ParseRotationError::Empty); } @@ -98,13 +100,13 @@ mod tests { assert_eq!( Rotation::from_str("3.a"), Err(ParseRotationError::ParseFloatError( - f32::from_str("3.a").expect_err("") + f32::from_str("3.a").expect_err("float parse should fail") )) ) } #[test] fn cant_parse_empty_string() { - assert_eq!(Rotation::from_str(""), Err(ParseRotationError::Empty)) + assert_eq!(Rotation::from_str(" "), Err(ParseRotationError::Empty)) } } -- cgit v1.2.3