diff --git a/src/macros.rs b/src/macros.rs index ebf1031..001002e 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -105,7 +105,7 @@ macro_rules! unpack_big_endian buffer = ::spellbook::components::Array::with_capacity($bytes); for i in 0..$bytes { - buffer.push(($value >> (($bytes - i) - 1) * 8) as u8); + buffer.insert_element(($value >> (($bytes - i) - 1) * 8) as u8); } // Return the buffer of bytes that represent this value. @@ -127,7 +127,7 @@ macro_rules! unpack_little_endian buffer = ::spellbook::components::Array::with_capacity($bytes); for i in 0..$bytes { - buffer.push(($value >> (i * 8)) as u8); + buffer.insert_element(($value >> (i * 8)) as u8); } // Return the buffer of bytes that represent this value. diff --git a/src/transmutable.rs b/src/transmutable.rs index d419bc4..78e1f6a 100644 --- a/src/transmutable.rs +++ b/src/transmutable.rs @@ -151,8 +151,12 @@ impl Transmutable for u8 #[allow(unused_variables)] fn as_endian_bytes(&self, endianess: Endianess) -> Array { - // A single byte has no endian form. - vec![*self] + let mut bytes: Array; + + bytes = Array::with_capacity(1usize); + bytes.insert_element(*self); + + bytes } fn determine_byte_size(&self) -> usize @@ -259,7 +263,12 @@ impl Transmutable for i8 #[allow(unused_variables)] fn as_endian_bytes(&self, endianess: Endianess) -> Array { - vec![*self as u8] + let mut bytes: Array; + + bytes = Array::with_capacity(1usize); + bytes.insert_element(*self as u8); + + bytes } fn determine_byte_size(&self) -> usize