mirror of
https://github.com/roc-lang/roc.git
synced 2025-07-24 06:55:15 +00:00
commit
fe0dad1136
5 changed files with 16 additions and 2 deletions
|
@ -152,6 +152,7 @@ impl Symbol {
|
|||
}
|
||||
|
||||
pub const fn to_ne_bytes(self) -> [u8; 8] {
|
||||
// repr(packed(4)) is repr(c), and with the fields as defined will not having padding.
|
||||
unsafe { std::mem::transmute(self) }
|
||||
}
|
||||
|
||||
|
|
|
@ -66,6 +66,7 @@ struct ErrorTypeState {
|
|||
recursive_tag_unions_seen: Vec<Variable>,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
struct SubsHeader {
|
||||
utable: u64,
|
||||
|
@ -99,10 +100,12 @@ impl SubsHeader {
|
|||
}
|
||||
|
||||
fn to_array(self) -> [u8; std::mem::size_of::<Self>()] {
|
||||
// Safety: With repr(c) all fields are in order and properly aligned without padding.
|
||||
unsafe { std::mem::transmute(self) }
|
||||
}
|
||||
|
||||
fn from_array(array: [u8; std::mem::size_of::<Self>()]) -> Self {
|
||||
// Safety: With repr(c) all fields are in order and properly aligned without padding.
|
||||
unsafe { std::mem::transmute(array) }
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue