Simply use debug_assert!() instead of cfg!(debug_assertions).
This commit is contained in:
parent
d65ccedc22
commit
86eaa73be0
|
@ -105,9 +105,7 @@ impl<T> ReadExt for T where T: io::Read {
|
||||||
|
|
||||||
// This function must not be called with more than 4 bytes.
|
// This function must not be called with more than 4 bytes.
|
||||||
pub fn atou16(bytes: &[u8]) -> Result<u16, Error> {
|
pub fn atou16(bytes: &[u8]) -> Result<u16, Error> {
|
||||||
if cfg!(debug_assertions) && bytes.len() >= 5 {
|
debug_assert!(bytes.len() <= 4);
|
||||||
panic!("atou16 accepts up to 4 bytes");
|
|
||||||
}
|
|
||||||
if bytes.len() == 0 {
|
if bytes.len() == 0 {
|
||||||
return Err(Error::InvalidFormat("Not a number"));
|
return Err(Error::InvalidFormat("Not a number"));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue