Simplified Rust code using ?-operator on Option (Rust 1.22).

pull/65/head
Project Nayuki 6 years ago
parent 20e904578e
commit 50d00ebf76

@ -1128,10 +1128,7 @@ impl QrSegment {
if seg.numchars >= 1 << ccbits { if seg.numchars >= 1 << ccbits {
return None; // The segment's length doesn't fit the field's bit width return None; // The segment's length doesn't fit the field's bit width
} }
match result.checked_add(4 + (ccbits as usize) + seg.data.len()) { result = result.checked_add(4 + (ccbits as usize) + seg.data.len())?;
None => return None, // The sum will overflow a usize type
Some(val) => result = val,
}
} }
Some(result) Some(result)
} }

Loading…
Cancel
Save