RFC: Statically enforce Unicode in std::fmt#526
Conversation
Statically enforce that the `std::fmt` module can only create valid UTF-8 data by removing the arbitrary `write` method in favor of a `write_str` method.
|
cc @SimonSapin |
|
👍 |
I think it’s fine for this trait to be in |
|
I seem to remember from way back when I was working on the base64 and hex modules that |
|
I'd probably be more in favor of an unsafe function to go from |
|
@sfackler Looks like Also, if the char/byte is literal, how does |
There was a problem hiding this comment.
Doesn't Result need to be instantiated?
There was a problem hiding this comment.
Ah ok, thanks. I somehow missed that one looking for other Results.
|
@SimonSapin I'd imagine that'd help, but I ran into this like ~1.5 years ago so my memory's a bit rusty :) @alexcrichton Yeah, implementations just transmuting from |
|
@sfackler You can always used |
|
Could it be confusing for newcomers for the stdlib to have two traits called Writer? Having to check to see which is in use, etc. |
|
@Sgeo I think we more or less have a convention to take advantage of the namespacing provided by modules and not try to duplicate it within names. Rather than have |
|
This RFC, which represents a longstanding request to enforce a strong Unicode convention and appears to have no real downsides, has been accepted. Tracking issue. |
|
I notice that in the "after" benchmark, |
Statically enforce that the
std::fmtmodule can only create valid UTF-8 databy removing the arbitrary
writemethod in favor of awrite_strmethod.Rendered