Document convention for using both fmt::Write and io::Write#37472
Merged
bors merged 1 commit intorust-lang:masterfrom Nov 9, 2016
Merged
Document convention for using both fmt::Write and io::Write#37472bors merged 1 commit intorust-lang:masterfrom
bors merged 1 commit intorust-lang:masterfrom
Conversation
…fmt::Write Various existing code does this, but the documentation doesn't explain how to do it.
Contributor
|
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @brson (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. Due to 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 the contribution instructions for more information. |
sophiajt
pushed a commit
to sophiajt/rust
that referenced
this pull request
Nov 2, 2016
…teln, r=alexcrichton Copyediting on documentation for write! and writeln! Fix various sentence fragments, missing articles, and other grammatical issues in the documentation for write! and writeln!. Also fix the links (and link names) for common return types. (Noticed when preparing rust-lang#37472 ; posted separately to avoid mixing the new documentation with copyedits to existing documentation.)
Contributor
|
@bors r+ rollup |
Collaborator
|
📌 Commit 955829c has been approved by |
eddyb
added a commit
to eddyb/rust
that referenced
this pull request
Nov 9, 2016
…, r=brson Document convention for using both fmt::Write and io::Write Using a trait's methods (like `Write::write_fmt` as used in `writeln!` and other macros) requires importing that trait directly (not just the module containing it). Both `fmt::Write` and `io::Write` provide compatible `Write::write_fmt` methods, and code can use `writeln!` and other macros on both an object implementing `fmt::Write` (such as a `String`) and an object implementing `io::Write` (such as `Stderr`). However, importing both `Write` traits produces an error due to the name conflict. The convention I've seen renames both of them on import, to `FmtWrite` and `IoWrite` respectively. Document that convention in the Rust documentation for `write!` and `writeln!`, with examples.
bors
added a commit
that referenced
this pull request
Nov 9, 2016
compiler-errors
added a commit
to compiler-errors/rust
that referenced
this pull request
Aug 27, 2022
…mulacrum Update documentation for `write!` and `writeln!` rust-lang#37472 added this documentation, but it needs updating: - Remove some documentation duplicated between `writeln!` and `write!` - Update `write!` docs: can now import traits as `_` to avoid conflicts - Expand example to show how to implement qualified trait names
JohnTitor
added a commit
to JohnTitor/rust
that referenced
this pull request
Aug 27, 2022
…mulacrum Update documentation for `write!` and `writeln!` rust-lang#37472 added this documentation, but it needs updating: - Remove some documentation duplicated between `writeln!` and `write!` - Update `write!` docs: can now import traits as `_` to avoid conflicts - Expand example to show how to implement qualified trait names
workingjubilee
pushed a commit
to tcdi/postgrestd
that referenced
this pull request
Sep 15, 2022
Update documentation for `write!` and `writeln!` rust-lang/rust#37472 added this documentation, but it needs updating: - Remove some documentation duplicated between `writeln!` and `write!` - Update `write!` docs: can now import traits as `_` to avoid conflicts - Expand example to show how to implement qualified trait names
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Using a trait's methods (like
Write::write_fmtas used inwriteln!and other macros) requires importing that trait directly (not just the module containing it). Bothfmt::Writeandio::Writeprovide compatibleWrite::write_fmtmethods, and code can usewriteln!and other macros on both an object implementingfmt::Write(such as aString) and an object implementingio::Write(such asStderr). However, importing bothWritetraits produces an error due to the name conflict.The convention I've seen renames both of them on import, to
FmtWriteandIoWriterespectively. Document that convention in the Rust documentation forwrite!andwriteln!, with examples.