Skip to content

Commit b183ee2

Browse files
Simplify type cast and remove error handling in protobuf exercise (#2755)
Co-authored-by: Dustin J. Mitchell <[email protected]>
1 parent 36c07e3 commit b183ee2

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

src/lifetimes/exercise.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,7 @@ fn parse_field(data: &[u8]) -> (Field<'_>, &[u8]) {
127127
}
128128
WireType::Len => {
129129
let (len, remainder) = parse_varint(remainder);
130-
let len: usize = len.try_into().expect("len not a valid `usize`");
131-
if remainder.len() < len {
132-
panic!("Unexpected EOF");
133-
}
130+
let len = len as usize; // cast for simplicity
134131
let (value, remainder) = remainder.split_at(len);
135132
(FieldValue::Len(value), remainder)
136133
}

0 commit comments

Comments
 (0)