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

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

Closed
SimonSapin opened this issue Nov 24, 2017 · 1 comment · Fixed by #46284
Closed

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

SimonSapin opened this issue Nov 24, 2017 · 1 comment · Fixed by #46284
Labels
C-cleanup Category: PRs that clean code up or issues documenting cleanup. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@SimonSapin
Copy link
Contributor

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

@sfackler
Copy link
Member

Yeah I think we'll want to deprecate it.

@kennytm kennytm added C-cleanup Category: PRs that clean code up or issues documenting cleanup. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. labels Nov 24, 2017
SimonSapin added a commit to SimonSapin/rust that referenced this issue Nov 26, 2017
bors added a commit that referenced this issue Nov 27, 2017
Deprecate the Formatter::flags method, fix #46237

This fixes #46237.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-cleanup Category: PRs that clean code up or issues documenting cleanup. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants