@phaux It’s not clear to me why “interpolated string literals” should only produce String and not &'static str (when given const/static arguments of course). I think features like interpolation probably ought to remain orthogonal to how literal typing works.
@arthurprs I agree that “special-casing String to allow static backing data” is way too magical, not to mention totally unnecessary for solving the original problem. But in the interests of moving the conversation forward, which of the alternative solutions do you prefer? New syntax for “owned string literals”? A macro with a very short name? Doing nothing at all?
@elszben The immediate problem is that with a proposal that broad, you need far stronger motivation than what we have in this thread. I want the vast majority of potentially-expensive methods like .to_string() and .into() to be explicit most of the time (especially since .into() could mean practically anything), and don’t know of any compelling reason why that principle should be changed. And that’s before we get to any of the tricky questions about how this would actually work with generics and inference and the other implicit conversions that Rust does do today.
@Nemo157 “User-defined literals” (as C++ calls this feature) are something I’d probably support if designed well and given enough compelling examples, but I see it as solving a different set of problems. What makes to_string() on literals annoying to me isn’t the number of characters to type, it’s that we have to provide any kind of explicit annotation at all when it’s perfectly obvious to the type system that this string literal has to be a String instead of a &'static str, but it still makes me do one extra round of see error message -> edit code -> recompile before letting me see useful output again. To me user-defined literals are most compelling for libraries dealing with types like dates, times, SQL queries, etc. which won’t get dedicated literal syntax in the core language, but can reasonably be represented by a single string or number.
(I haven’t read gankro’s new post yet, but since I already typed up all this and that’s gonna take a while to digest I’ll just post this now)