Email or username:

Password:

Forgot your password?
Jonathan ‘theJPster’ Pallant

github.com/rust-lang/rust/pull

Soon you will be able to write c"Hello" in rust and get a valid UTF-8 encoded *NUL-terminated* string. This is amazing for people who work with C APIs.

5 comments
chrysn

@thejpster I'm conflicted about this. Sure it's nice ergonomics, but `cstr!(...)` wasn't that bad, and it feels like it's giving a foreign language construct more weight in the language than it should have. Yeah it's used widely, but so is `hexlit!(...)`, and where do we stop.

Jonathan ‘theJPster’ Pallant

@chrysn was cstr! in libcore?

As someone who has to make Rust talk to things that already exist, I’m happy it’s going in - C is not a language it’s an ABI and it’s an ABI Rust claims to support.

chrysn

@thejpster It wasn't, but it could have been even more easily than adding c"" (especially in core that has access to const_eval_select); until then, cstr crate provided it.
Yeah, there are probably good reasons; still don't like the taste of it.

Maybe I should go do something fun and then I'll be less weird about it.

Adriano

@thejpster “you’re only encouraging them”

Go Up