return early from de_position with ?
This commit is contained in:
parent
ff215567d5
commit
aa770c7b1c
|
@ -99,14 +99,13 @@ mod helpers {
|
||||||
/// The input string here is either a number or two numbers separated by `SEPARATOR`.
|
/// The input string here is either a number or two numbers separated by `SEPARATOR`.
|
||||||
pub fn de_position<'de, D>(deserializer: D) -> Result<Option<Position>, D::Error>
|
pub fn de_position<'de, D>(deserializer: D) -> Result<Option<Position>, D::Error>
|
||||||
where D: de::Deserializer<'de> {
|
where D: de::Deserializer<'de> {
|
||||||
if let Ok(s) = String::deserialize(deserializer) {
|
let s = String::deserialize(deserializer)?;
|
||||||
let mut ints = s.split(SEPARATOR).map(u16::from_str);
|
let mut ints = s.split(SEPARATOR).map(u16::from_str);
|
||||||
if let Some(Ok(n)) = ints.next() {
|
if let Some(Ok(n)) = ints.next() {
|
||||||
return Ok(Some(Position {
|
return Ok(Some(Position {
|
||||||
item_position: n,
|
item_position: n,
|
||||||
total_items: ints.next().and_then(Result::ok),
|
total_items: ints.next().and_then(Result::ok),
|
||||||
}));
|
}));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Ok(None)
|
Ok(None)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user