Skip to content

Why does fmt::Formatter have a public flags() method? Should we deprecate it? #46237

Closed
@SimonSapin

Description

@SimonSapin

https://doc.rust-lang.org/std/fmt/struct.Formatter.html#method.flags

impl<'a> Formatter<'a> {
    // ...

    /// Flags for formatting
    #[stable(feature = "rust1", since = "1.0.0")]
    pub fn flags(&self) -> u32 { self.flags }
}

This method is public, but its documentation doesn’t say anything about the meaning of the return value. The bit indices to interpret it are given by the numerical value of variants of the FlagV1 enum. But that enum is private, and all of that information is exposed in other public methods (sign_plus, sign_minus, alternate, sign_aware_zero_pad) so it looks like the details of that encoding are intended to be private.

It looks like there is no way of using that method without making assumptions about private implementation details that we might want to change. Should we document it as such and deprecate it?

CC @rust-lang/libs

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-cleanupCategory: PRs that clean code up or issues documenting cleanup.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