-
Notifications
You must be signed in to change notification settings - Fork 179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use a stable repr to enable safe casting #359
Comments
This is actually something I looked at a while ago and would be open to adding it again. Perhaps to begin with, placing it behind a feature flag could be useful for experimentation purposes. |
Just for the record. rust-lang/rust#81996 |
From my understanding of the issue mentioned by @c410-f3r, However, for some additional sanity, I think it would be better to add some layout assertion tests, to make sure the layout is really what we expect. In that case, simply making sure the size of the decimal type is 16 bytes would be enough, I believe. |
This adds the c-repr feature which forces `Decimal` to be #[repr(C)]. Closes paupino#359.
I've been looking in storing
Decimal
inline in c struct so that I don't have to pay serialization & deserialization cost. However I've noticed that theDecimal
type does not have a stable ABI represenation.Would you consider using
#[repr(C)]
or#[repr(u128])
in order to provide a stable ABI? This would basically deprecate theserialize
&deserialize
methods, but lock-in the current inner represation. I'm guessing this shouldn't impact performance.For my use case, the main benefit would be to be able to safely cast a
&[u8]
into&[Decimal]
, which currently cannot be done safely without allocating an intermediary buffer etc.The text was updated successfully, but these errors were encountered: