further simplify de_position
This commit is contained in:
parent
aa770c7b1c
commit
9b73d95340
|
@ -100,11 +100,11 @@ mod helpers {
|
|||
pub fn de_position<'de, D>(deserializer: D) -> Result<Option<Position>, 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)
|
||||
|
|
Loading…
Reference in New Issue