You've already forked comprehensive-rust
mirror of
https://github.com/google/comprehensive-rust.git
synced 2025-12-21 14:35:47 +02:00
Simplify type cast and remove error handling in protobuf exercise (#2755)
Co-authored-by: Dustin J. Mitchell <dustin@v.igoro.us>
This commit is contained in:
@@ -127,10 +127,7 @@ fn parse_field(data: &[u8]) -> (Field<'_>, &[u8]) {
|
||||
}
|
||||
WireType::Len => {
|
||||
let (len, remainder) = parse_varint(remainder);
|
||||
let len: usize = len.try_into().expect("len not a valid `usize`");
|
||||
if remainder.len() < len {
|
||||
panic!("Unexpected EOF");
|
||||
}
|
||||
let len = len as usize; // cast for simplicity
|
||||
let (value, remainder) = remainder.split_at(len);
|
||||
(FieldValue::Len(value), remainder)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user