-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Conversation
The provided example to the `sign_plus` method on `fmt` is broken, it displays the `-` sign twice for negative numbers.
Hey! It looks like you've submitted a new PR for the library teams! If this PR contains changes to any Examples of
|
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. |
There was a problem hiding this 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_eq
s?
assert_eq!(&format!("{:+}", Foo(23)), "Foo(+23)");
assert_eq!(&format!("{}", Foo(23)), "Foo(23)");
// ADD Foo(-23) HERE
Fixed |
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? |
@bors r+ rollup |
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.
…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
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
The provided example to the
sign_plus
method onfmt
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.