ruabmbua / hidapi-rs

Rust bindings for the hidapi C library
MIT License
172 stars 81 forks source link

HidError is a bit large #45

Closed lnicola closed 5 years ago

lnicola commented 5 years ago

The 1.0 ship has sailed now (:tada:), but HidError is somewhat on the large side because of its HidDeviceInfo variant: 112 bytes on x64. Unfortunately, the compiler isn't too good at avoiding implicit copies (made for moves), so it's worth boxing it.

ruabmbua commented 5 years ago

Yea thats a good idea. I will try to make a fix.

lnicola commented 5 years ago

The problem is that the variant is public, so changing its type would technically be a breaking change. Maybe you can replace HidDeviceInfo with a boxed value, but..

ruabmbua commented 5 years ago

Resolved in https://github.com/ruabmbua/hidapi-rs/commit/c2a044d7ec2036b4b63b7997523ed2041ae7025e

ruabmbua commented 5 years ago

I just updated it to 1.0.1, I hope no one upgraded to 1.0.0 already.

Edit: To be honest, I did not realize, that Rust implies that enum variant members are public. Makes sense because of the pattern matching... Never crossed my mind before.

lnicola commented 5 years ago

I upgraded, but don't worry :smile:. You can yank it, I suppose, but maybe nobody is looking at the fields in the error variants. It's very easy to break semver compat this way, though.

ruabmbua commented 5 years ago

I`ll yank 1.0.0 :P