When developing WASM in Rust, we could use #[repr(C)] to handle structures like enum and struct to have C-like layouts. We could also use std::ffi::CString to have C-like strings.
For other common Rust types, like Option, Result, Vec, and String, we use #![feature(wasm_abi)] to handle them. But the ABI of these types seems not consistent in different Rust versions.We've tried using different nightly versions of Rust and have different layouts.
Do we have any way to have consistent ABI across different Rust versions? Thanks!
Option, Result, Vec and String don't have a stable layout. (except for Option<&T>, Option<&mut T>, Option<NonNull<T>> and Option<NonZero*>) You will need to define your own types with a stable layout and convert between them.