You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#2625 makes an assumption that String can be transmuted into Vec<u8>. Usually repr(Rust) structures don't offer any guarantees on the representation of the object in memory. However, this comment made some points in favor of making this assumption.
We should consider special handling String conversion in FFI instead of transmuting it into Vec<u8>
The text was updated successfully, but these errors were encountered:
After some investigation it was found that repr(rust) single-field structs is guaranteed to have the same memory layout as it's single field (Unsafe Code Guidelines Reference).
Currently String is implemented as single-field struct (source) so it's transmutable into Vec<u8>.
There is still chance that String layout will be changed in the future, but this seems unlikely and could be fixed later.
#2625 makes an assumption that
String
can be transmuted intoVec<u8>
. Usuallyrepr(Rust)
structures don't offer any guarantees on the representation of the object in memory. However, this comment made some points in favor of making this assumption.We should consider special handling
String
conversion in FFI instead of transmuting it intoVec<u8>
The text was updated successfully, but these errors were encountered: