Change some static assertions to debug_assert
This commit is contained in:
parent
cdb579c101
commit
5c04a059d5
|
@ -249,7 +249,7 @@ macro_rules! decoder_fn {
|
|||
($name:ident, $val_type:ty, $readfn:ident, $byte_len: expr) => {
|
||||
#[inline]
|
||||
fn $name(&mut self) -> Result<$val_type, Error> {
|
||||
assert_eq!(::std::mem::size_of::<$val_type>(), $byte_len); // size_of isn't a constfn in 1.22
|
||||
debug_assert_eq!(::std::mem::size_of::<$val_type>(), $byte_len); // size_of isn't a constfn in 1.22
|
||||
let mut val = [0; $byte_len];
|
||||
self.read_exact(&mut val[..]).map_err(Error::Io)?;
|
||||
Ok(endian::$readfn(&val))
|
||||
|
|
|
@ -28,7 +28,7 @@ macro_rules! define_be_to_array {
|
|||
($name: ident, $type: ty, $byte_len: expr) => {
|
||||
#[inline]
|
||||
pub fn $name(val: $type) -> [u8; $byte_len] {
|
||||
assert_eq!(::std::mem::size_of::<$type>(), $byte_len); // size_of isn't a constfn in 1.22
|
||||
debug_assert_eq!(::std::mem::size_of::<$type>(), $byte_len); // size_of isn't a constfn in 1.22
|
||||
let mut res = [0; $byte_len];
|
||||
for i in 0..$byte_len {
|
||||
res[i] = ((val >> ($byte_len - i - 1)*8) & 0xff) as u8;
|
||||
|
@ -41,7 +41,7 @@ macro_rules! define_le_to_array {
|
|||
($name: ident, $type: ty, $byte_len: expr) => {
|
||||
#[inline]
|
||||
pub fn $name(val: $type) -> [u8; $byte_len] {
|
||||
assert_eq!(::std::mem::size_of::<$type>(), $byte_len); // size_of isn't a constfn in 1.22
|
||||
debug_assert_eq!(::std::mem::size_of::<$type>(), $byte_len); // size_of isn't a constfn in 1.22
|
||||
let mut res = [0; $byte_len];
|
||||
for i in 0..$byte_len {
|
||||
res[i] = ((val >> i*8) & 0xff) as u8;
|
||||
|
|
Loading…
Reference in New Issue