Replace cfg!(debug_assertions) with debug_assert!

This commit is contained in:
Michael Pfaff 2022-03-03 07:46:12 -05:00
parent d10edd35a5
commit 5c1446df00
Signed by: michael
GPG Key ID: F1A27427218FCA77
1 changed files with 1 additions and 3 deletions

View File

@ -105,9 +105,7 @@ impl<T> ReadExt for T where T: io::Read {
// This function must not be called with more than 4 bytes.
pub fn atou16(bytes: &[u8]) -> Result<u16, Error> {
if cfg!(debug_assertions) && bytes.len() >= 5 {
panic!("atou16 accepts up to 4 bytes");
}
debug_assert!(bytes.len() <= 4, "atou16 accepts up to 4 bytes");
if bytes.len() == 0 {
return Err(Error::InvalidFormat("Not a number"));
}