Skip to content

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

Open
@dead-claudia

Description

@dead-claudia

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    F-c_str_literals`#![feature(c_str_literals)]`T-langRelevant to the language team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions