6 ms·
Yeah, it looks like this would be problem for Rust’s `String` (owned) although not `&str` (borrowed).
by avgcorrection 3y ago
Yeah, it looks like this would be problem for Rust’s `String` (owned) although not `&str` (borrowed).
- tialaramex 3y agoInside Rust it doesn't matter, because Rust gets to pick its own ABI rules. So this only matters for the FFI case and it's probably usually a bad idea to give a mutable String (as opposed to a read-only &str) to foreign language code. Likewise for Vec<T> and &[T] indeed underneath Rust's String is literally Vec<u8> and &str is literally &[u8] but in both cases with the explicit requirement that the bytes are valid UTF-8 text.