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

Tracking issue for Unicode enforcement in std::fmt (RFC 526) #20352

Closed
aturon opened this issue Dec 30, 2014 · 1 comment · Fixed by #20377
Closed

Tracking issue for Unicode enforcement in std::fmt (RFC 526) #20352

aturon opened this issue Dec 30, 2014 · 1 comment · Fixed by #20377
Labels
B-RFC-approved Blocker: Approved by a merged RFC but not yet implemented.

Comments

@aturon
Copy link
Member

aturon commented Dec 30, 2014

RFC

@aturon aturon added A-libs B-RFC-approved Blocker: Approved by a merged RFC but not yet implemented. labels Dec 30, 2014
@aturon
Copy link
Member Author

aturon commented Dec 30, 2014

cc @alexcrichton

alexcrichton added a commit to alexcrichton/rust that referenced this issue Jan 2, 2015
This commit is an implementation of [RFC 526][rfc] which is a change to alter
the definition of the old `fmt::FormatWriter`. The new trait, renamed to
`Writer`, now only exposes one method `write_str` in order to guarantee that all
implementations of the formatting traits can only produce valid Unicode.

[rfc]: https://github.com/rust-lang/rfcs/blob/master/text/0526-fmt-text-writer.md

One of the primary improvements of this patch is the performance of the
`.to_string()` method by avoiding an almost-always redundant UTF-8 check. This
is a breaking change due to the renaming of the trait as well as the loss of the
`write` method, but migration paths should be relatively easy:

* All usage of `write` should move to `write_str`. If truly binary data was
  being written in an implementation of `Show`, then it will need to use a
  different trait or an altogether different code path.

* All usage of `write!` should continue to work as-is with no modifications.

* All usage of `Show` where implementations just delegate to another should
  continue to work as-is.

[breaking-change]

Closes rust-lang#20352
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
B-RFC-approved Blocker: Approved by a merged RFC but not yet implemented.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant