Skip to content

Commit d638b98

Browse files
authored
Merge pull request #50 from hashmismatch/big_endian_fix
Fixes for other platforms
2 parents b9b2003 + 34ea542 commit d638b98

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ Bit-level packing and unpacking for Rust
33

44
[![Crates.io][crates-badge]][crates-url]
55
[![Documentation](https://docs.rs/packed_struct/badge.svg)](https://docs.rs/packed_struct)
6+
![master](https://github.com/hashmismatch/packed_struct.rs/workflows/Rust/badge.svg)
67

78
[crates-badge]: https://img.shields.io/crates/v/packed_struct.svg
89
[crates-url]: https://crates.io/crates/packed_struct

packed_struct/src/types_num.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -164,13 +164,12 @@ macro_rules! integer_as_bytes {
164164

165165
#[inline]
166166
fn to_msb_bytes(&self) -> [u8; $N] {
167-
let n = self.to_le();
168-
as_bytes!($N, n)
167+
as_bytes!($N, self)
169168
}
170169

171170
#[inline]
172171
fn to_lsb_bytes(&self) -> [u8; $N] {
173-
let n = self.to_be();
172+
let n = self.swap_bytes();
174173
as_bytes!($N, n)
175174
}
176175

@@ -182,7 +181,7 @@ macro_rules! integer_as_bytes {
182181
#[inline]
183182
fn from_lsb_bytes(bytes: &[u8; $N]) -> Self {
184183
let n = from_bytes!($N, bytes, $T);
185-
n.to_be()
184+
n.swap_bytes()
186185
}
187186
}
188187
};

packed_struct_tests/tests/primitive_enum_types.rs

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ pub enum EnumU16 {
1616
VariantMax = 65535
1717
}
1818

19+
#[repr(u32)]
1920
#[derive(PrimitiveEnum, PartialEq, Debug, Clone, Copy)]
2021
pub enum EnumU32 {
2122
VariantMin = 0,

0 commit comments

Comments
 (0)