woboq / qmetaobject-rs

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

Mitigate 128-bit TypeId hash #300

Closed direc85 closed 10 months ago

direc85 commented 10 months 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 10 months ago

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

direc85 commented 10 months 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 10 months ago

thanks for your patch anyway.