From 9b73d95340f7ac6ace376f07976e4f8ef66de0a4 Mon Sep 17 00:00:00 2001 From: kageru Date: Sun, 21 Jun 2020 00:00:24 +0200 Subject: [PATCH] further simplify de_position --- src/structs.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/structs.rs b/src/structs.rs index 51e647d..5c1521b 100644 --- a/src/structs.rs +++ b/src/structs.rs @@ -100,11 +100,11 @@ mod helpers { pub fn de_position<'de, D>(deserializer: D) -> Result, D::Error> where D: de::Deserializer<'de> { let s = String::deserialize(deserializer)?; - let mut ints = s.split(SEPARATOR).map(u16::from_str); - if let Some(Ok(n)) = ints.next() { + let mut ints = s.split(SEPARATOR).filter_map(|s| u16::from_str(s).ok()); + if let Some(n) = ints.next() { return Ok(Some(Position { item_position: n, - total_items: ints.next().and_then(Result::ok), + total_items: ints.next(), })); } Ok(None)