Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upAdd a write_char method to std::fmt::Formatter. #24689
Conversation
rust-highfive
assigned
alexcrichton
Apr 22, 2015
This comment has been minimized.
This comment has been minimized.
|
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @alexcrichton (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. The way Github handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see CONTRIBUTING.md for more information. |
This comment has been minimized.
This comment has been minimized.
|
Hm can you clarify why you'd want this as an inherent method? It seems like a similar win is gained from implementing |
This comment has been minimized.
This comment has been minimized.
|
I only made it an inherent method because I don’t have a strong opinion on how to do this, or if it should be done at all. |
This comment has been minimized.
This comment has been minimized.
|
I think it would be safe to provide an implementation of the trait for |
alexcrichton
added
T-libs
I-needs-decision
labels
May 26, 2015
This comment has been minimized.
This comment has been minimized.
|
@SimonSapin could you try adding this method through an implementation of the |
alexcrichton
removed
the
I-needs-decision
label
Jun 10, 2015
SimonSapin
force-pushed the
SimonSapin:formatter-write-char
branch
from
b3c46d0
to
10fbce3
Jun 10, 2015
This comment has been minimized.
This comment has been minimized.
|
Done. (Now the trait has to be in scope to use that method, of course.) |
alexcrichton
reviewed
Jun 10, 2015
| @@ -892,6 +892,20 @@ impl<'a> Formatter<'a> { | |||
| } | |||
| } | |||
|
|
|||
| impl<'a> Write for Formatter<'a> { | |||
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
r=me with a stability tag, thanks @SimonSapin! |
SimonSapin
force-pushed the
SimonSapin:formatter-write-char
branch
from
10fbce3
to
63da18b
Jun 10, 2015
This comment has been minimized.
This comment has been minimized.
bors
added a commit
that referenced
this pull request
Jun 10, 2015
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
bors
merged commit 63da18b
into
rust-lang:master
Jun 10, 2015
SimonSapin
deleted the
SimonSapin:formatter-write-char
branch
Jun 10, 2015
SimonSapin
reviewed
Jun 29, 2015
| let mut utf8 = [0; 4]; | ||
| let amt = self.encode_utf8(&mut utf8).unwrap_or(0); | ||
| let s: &str = unsafe { mem::transmute(&utf8[..amt]) }; | ||
| Display::fmt(s, f) |
This comment has been minimized.
This comment has been minimized.
SimonSapin
Jun 29, 2015
Author
Contributor
Ah, yes, my mistake. Feel free to reverse this chunk if there isn’t a better solution.
SimonSapin commentedApr 22, 2015
This is the logical next step after #24661, but I’m less sure about this one.
r? @alexcrichton