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`.
|
||||
pub fn de_position<'de, D>(deserializer: D) -> Result<Option<Position>, D::Error>
|
||||
where D: de::Deserializer<'de> {
|
||||
if let Ok(s) = String::deserialize(deserializer) {
|
||||
let mut ints = s.split(SEPARATOR).map(u16::from_str);
|
||||
if let Some(Ok(n)) = ints.next() {
|
||||
return Ok(Some(Position {
|
||||
item_position: n,
|
||||
total_items: ints.next().and_then(Result::ok),
|
||||
}));
|
||||
}
|
||||
let s = String::deserialize(deserializer)?;
|
||||
let mut ints = s.split(SEPARATOR).map(u16::from_str);
|
||||
if let Some(Ok(n)) = ints.next() {
|
||||
return Ok(Some(Position {
|
||||
item_position: n,
|
||||
total_items: ints.next().and_then(Result::ok),
|
||||
}));
|
||||
}
|
||||
Ok(None)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user