In both these cases, we know the length of the buffer in a variable that's already of the same type, so just use that value instead — and that's how all the other record parsers do it, too.
@@ -35,7 +35,7 @@ impl Wire for A {
}
else {
warn!("Length is incorrect (record length {:?}, but should be four)", len);
- Err(WireError::WrongRecordLength { expected: 4, got: buf.len() as u16 })
+ Err(WireError::WrongRecordLength { expected: 4, got: len })
@@ -37,7 +37,7 @@ impl Wire for AAAA {
warn!("Length is incorrect (record length {:?}, but should be sixteen)", len);
- Err(WireError::WrongRecordLength { expected: 16, got: buf.len() as u16 })
+ Err(WireError::WrongRecordLength { expected: 16, got: len })