Skip to content

Don't discourage people from using std::fmt::Write #76729

Closed
@camelid

Description

@camelid

The docs for std::fmt::Write discourage using it outside of the standard library:

[…] This is similar to the standard library's io::Write trait, but it is only intended for use in libcore.

This trait should generally not be implemented by consumers of the standard library. The write! macro accepts an instance of io::Write, and the io::Write trait is favored over implementing this trait.

Yet it is relatively often that one needs a trait for writing Unicode to a stream. For example, pulldown-cmark has a trait very similar to this one called StrWrite.

When I asked in Zulip, nobody seemed to know why that comment is there.

It would be good to have a standard that every library can use for this.


@rustbot modify labels: A-fmt T-libs T-doc

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsA-fmtArea: `core::fmt`T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions