Skip to content

Commit ca9649d

Browse files
authored
Merge pull request #167 from mrxr16/fix32bit
32 bit build fix
2 parents 7777a8a + 80f2e7e commit ca9649d

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

gdnative-core/src/rid.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,13 @@ impl Rid {
2727
}
2828

2929
fn to_u64(&self) -> u64 {
30-
unsafe { transmute(self.0) }
30+
unsafe {
31+
// std::mem::transmute needs source and destination types to have the same size. On 32
32+
// bit systems sizeof(void *) != size_of<u64>() so this fails to compile. The bindings
33+
// define godot_rid as (a newtype of) [u8; u8size] or [u8; u4size] depending on
34+
// architecture word size so transmuting to usize should always work.
35+
transmute::<_, usize>(self.0) as _
36+
}
3137
}
3238

3339
#[doc(hidden)]

0 commit comments

Comments
 (0)