Skip to content

Commit 7651870

Browse files
committed
Add implicit "" idea.
1 parent a1306b6 commit 7651870

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

text/3348-c-str-literal.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,14 @@ Interactions with string related macros:
6060
Even if we had the right language features for a trivial correct implementation, there are many code bases where C strings are the primary form of string,
6161
making `cstr!("..")` syntax quite cumbersome.
6262

63+
- No `c""` literal, but make it possible for `""` to implicitly become a `&CStr` through magic.
64+
65+
We already allow integer literals (e.g. `123`) to become one of many types, so perhaps we could do the same to string literals.
66+
67+
(It could be a built-in fixed set of types (e.g. just `str`, `[u8]`, and `CStr`),
68+
or it could be something extensible through something like a `const trait FromStringLiteral`.
69+
Not sure how that would exactly work, but it sounds cool.)
70+
6371
* Allowing only valid UTF-8 and unicode-oriented escape codes (like in `"…"`, e.g. `螃蟹` or `\u{1F980}` but not `\xff`).
6472

6573
For regular string literals, we have this restriction because `&str` is required to be valid UTF-8.

0 commit comments

Comments
 (0)