Re:Compiling C to Safe Rust, Formalized
by whytevuhuni on Saturday December 21, 2024 @04:12PM
(#42482331)
They likely mean a char* pointer to a null-terminated string, or a char* pointer and a length, as is usual for C.
If Rust was forced to expose such an API (to be on par with C's old API), it would have to deal with non-UTF8 inputs throughout its whole codebase, which is a lot more inconvenient. A lot of methods, like .split_ascii_whitespace, are missing on &[u8]. A lot of libraries won't take anything but a &str.
Or they might be tempted to convert such an input to a String, in which case the semantics will differ (it will now panic on non-UTF8 inputs).
If Rust was forced to expose such an API (to be on par with C's old API), it would have to deal with non-UTF8 inputs throughout its whole codebase, which is a lot more inconvenient. A lot of methods, like .split_ascii_whitespace, are missing on &[u8]. A lot of libraries won't take anything but a &str.
Or they might be tempted to convert such an input to a String, in which case the semantics will differ (it will now panic on non-UTF8 inputs).