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

Fix the example code and doctest for Formatter::sign_plus #101529

Merged
merged 3 commits into from
Sep 9, 2022

Conversation

mousetail
Copy link
Contributor

The provided example to the sign_plus method on fmt was broken, it displays the - sign twice for negative numbers.

This pull request should fix the issue by .abs() ing the number so that the negative sign appears only once. It is just one possible solution to the issue, not sure if it's the best. However, this one will behave as expected when combined with fill and alignment operators.

The provided example to the `sign_plus` method on `fmt` is broken, it displays the `-` sign twice for negative numbers.
@rustbot rustbot added the T-libs Relevant to the library team, which will review and decide on the PR/issue. label Sep 7, 2022
@rustbot
Copy link
Collaborator

rustbot commented Sep 7, 2022

Hey! It looks like you've submitted a new PR for the library teams!

If this PR contains changes to any rust-lang/rust public library APIs then please comment with @rustbot label +T-libs-api -T-libs to tag it appropriately. If this PR contains changes to any unstable APIs please edit the PR description to add a link to the relevant API Change Proposal or create one if you haven't already. If you're unsure where your change falls no worries, just leave it as is and the reviewer will take a look and make a decision to forward on if necessary.

Examples of T-libs-api changes:

  • Stabilizing library features
  • Introducing insta-stable changes such as new implementations of existing stable traits on existing stable types
  • Introducing new or changing existing unstable library APIs (excluding permanently unstable features / features without a tracking issue)
  • Changing public documentation in ways that create new stability guarantees
  • Changing observable runtime behavior of library APIs

@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @thomcc (or someone else) soon.

Please see the contribution instructions for more information.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 7, 2022
Copy link
Member

@fee1-dead fee1-dead left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a doctest below, near the assert_eqs?

assert_eq!(&format!("{:+}", Foo(23)), "Foo(+23)");
assert_eq!(&format!("{}", Foo(23)), "Foo(23)");
// ADD Foo(-23) HERE

@mousetail
Copy link
Contributor Author

Could you add a doctest below, near the assert_eqs?

assert_eq!(&format!("{:+}", Foo(23)), "Foo(+23)");
assert_eq!(&format!("{}", Foo(23)), "Foo(23)");
// ADD Foo(-23) HERE

Fixed

@thomcc
Copy link
Member

thomcc commented Sep 7, 2022

Looks good, but do you mind squashing your commits into one and giving that one a slightly more specific message (Maybe something along the lines of "Fix doctest for Formatter::sign_plus")?

Thanks!

@mousetail mousetail changed the title This example was broken Fix the example code and doctest for Formatter::sign_plus Sep 7, 2022
@mousetail
Copy link
Contributor Author

Looks good, but do you mind squashing your commits into one and giving that one a slightly more specific message (Maybe something along the lines of "Fix doctest for Formatter::sign_plus")?

Thanks!

I changed the name. Not sure how to squash commits from the web UI though. Won't the merge process do this automatically?

@thomcc
Copy link
Member

thomcc commented Sep 9, 2022

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Sep 9, 2022

📌 Commit 5fbe485 has been approved by thomcc

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 9, 2022
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request Sep 9, 2022
Fix the example code and doctest for Formatter::sign_plus

The provided example to the `sign_plus` method on `fmt` was broken, it displays the `-` sign twice for negative numbers.

This pull request should fix the issue by `.abs()` ing the number so that the negative sign appears only once. It is just one possible solution to the issue, not sure if it's the best. However, this one will behave as expected when combined with fill and alignment operators.
bors added a commit to rust-lang-ci/rust that referenced this pull request Sep 9, 2022
…llaumeGomez

Rollup of 5 pull requests

Successful merges:

 - rust-lang#101475 (Use futex-based locks and thread parker on Hermit)
 - rust-lang#101492 (Suggest adding array lengths to references to arrays if possible)
 - rust-lang#101495 (Compile spin_loop_hint as pause on x86 even without sse2 enabled)
 - rust-lang#101529 (Fix the example code and doctest for Formatter::sign_plus)
 - rust-lang#101600 (rustdoc: simplify the codeblock tooltip)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit to rust-lang-ci/rust that referenced this pull request Sep 9, 2022
Rollup of 5 pull requests

Successful merges:

 - rust-lang#101366 (Restore old behaviour on broken UNC paths)
 - rust-lang#101492 (Suggest adding array lengths to references to arrays if possible)
 - rust-lang#101529 (Fix the example code and doctest for Formatter::sign_plus)
 - rust-lang#101573 (update `ParamKindOrd`)
 - rust-lang#101612 (Fix code generation of `Rvalue::Repeat` with 128 bit values)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit ff21ccf into rust-lang:master Sep 9, 2022
@rustbot rustbot added this to the 1.65.0 milestone Sep 9, 2022
@mousetail mousetail deleted the patch-2 branch September 12, 2022 10:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants