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
This issue is part of the libs-api team API change proposal process. Once this issue is filed the libs-api team will review open proposals in its weekly meeting. You should receive feedback within a week or two.
The text was updated successfully, but these errors were encountered:
I'm broadly in favor of this -- it's worth considering what syntax we'd want for this under rust-lang/rfcs#3267 (although, I guess I'm unsure the future that RFC has).
I actually just ran into this! I'll echo Thom about broadly wanting this and say that I'd prefer Mara's solution over a macro, but would settle for either.
Proposal
Problem statement
Now that
core::ffi::CStr
is stabilized, there should be an ergonomic way to create&CStr
constants.Motivation, use-cases
On stable there is currently no good way to create a
&'static CStr
, the simplest solution needsunsafe
, i.e.On nightly, it is possible since rust-lang/rust#100291 without
unsafe
, but these are even more verbose or don't provide meaningful error messages:Solution sketches
With a
cstr!
, the example above becomes both easier to write and easier to read, i.e.Links and related work
cstr_core
crate contains such a macro: https://docs.rs/cstr_core/0.2.6/cstr_core/macro.cstr.htmlcstr
crate provides such a macro: https://docs.rs/cstr/0.2.10/cstr/index.htmlcore::ffi::cstr
is here: Addcstr!
macro. rust#101607What happens now?
This issue is part of the libs-api team API change proposal process. Once this issue is filed the libs-api team will review open proposals in its weekly meeting. You should receive feedback within a week or two.
The text was updated successfully, but these errors were encountered: