woboq / qmetaobject-rs

Integrate Qml and Rust by building the QMetaObject at compile time.
MIT License
647 stars 89 forks source link

Mitigate 128-bit TypeId hash #300

Closed direc85 closed 1 year ago

direc85 commented 1 year ago

Obviously, this breaks Rust <1.72, but I couldn't find a neat way to conditionally include the changes using. It doesn't seem to be possible to have something like #[cfg(version >= "1.72")] or #[cfg(TYPE_ID_SIZE == 16)], or perhaps I just didn't find the correct keyword to use.

Not sure if either method is good enough for master, but at least there's something that works:

Approach 1: unsafe { transmute }

Approach 2: Custom hasher which utilizes TypeId.hash() which internally casts u128u64

Improvements and further ideas welcome :sweat_smile:

Fixes #299

rubdos commented 1 year ago

Would it not be better to upsize the older Rust types, instead of chopping the new one?

direc85 commented 1 year ago

As said in the issue, this is fixed already in master, I'm only affected because I'm running 0.2.5-ish due to Rust 1.52.1. Closing as irrelevant.

ogoffart commented 1 year ago

thanks for your patch anyway.