Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C string literals can't just use a trivial conversion from regular string or byte literals #106479

Open
dead-claudia opened this issue Jan 5, 2023 · 3 comments
Labels
F-c_str_literals `#![feature(c_str_literals)]` T-lang Relevant to the language team, which will review and decide on the PR/issue.

Comments

@dead-claudia
Copy link

Initial comment

In the "Rationale and alternatives" section of RFC 3348, it mentions a hypothetical FromStringLiteral. While I like the idea, it couldn't be as simple as a From<&'static str>/TryFrom<&'static str>: error messages would need at least a character offset + string message to be more useful than just "hey, this string contains a problem character". Also, &CStrs are really more like byte string literals, and that offset would have to be a byte offset, not a char offset, too.

This probably could justify the existence of such a trait, though. C string literals in particular wouldn't push the boundaries much, but I could see other things like regular expressions benefitting a ton from it.

@dead-claudia
Copy link
Author

@rustbot label +F-c_str_literal +T-lang

@rustbot rustbot added F-c_str_literals `#![feature(c_str_literals)]` T-lang Relevant to the language team, which will review and decide on the PR/issue. labels Jan 13, 2023
@tgross35
Copy link
Contributor

Would you mind updating the title to something that describes the desired action/behavior? It doesn't make much sense to be describing a problem with behavior if that behavior doesn't exist at all 🙂

And if #105723 is stabilized and closed, this will be the only place tracking that idea

@dead-claudia
Copy link
Author

@tgross35 I was just calling out a specific caveat with one of the ideas in the C string literal's RFC, specifically with the FromStringLiteral idea.

If there's no FromStringLiteral, there's no issue here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-c_str_literals `#![feature(c_str_literals)]` T-lang Relevant to the language team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants