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

Rename Div operator trait to Quot and Modulo operator trait to Rem #5990

Merged
merged 1 commit into from
Apr 21, 2013

Conversation

brendanzab
Copy link
Member

This renaming, proposed in the Numeric Bikeshed, will allow us to implement div and and modulo methods that follow the conventional mathematical definitions for negative numbers without altering the definitions of the operators (and confusing systems programmers). Here is a useful answer on StackOverflow that explains the difference between div/mod and quot/rem in Haskell: (When is the difference between quotRem and divMod useful?)[http://stackoverflow.com/a/339823/679485].

This is part of the numeric trait reforms tracked in issue #4819.

bors added a commit that referenced this pull request Apr 21, 2013
This renaming, proposed in the [Numeric Bikeshed](https://github.com/mozilla/rust/wiki/Bikeshed-Numeric-Traits#rename-modulo-into-rem-or-remainder-in-traits-and-docs), will allow us to implement div and and modulo methods that follow the conventional mathematical definitions for negative numbers without altering the definitions of the operators (and confusing systems programmers). Here is a useful answer on StackOverflow that explains the difference between `div`/`mod` and `quot`/`rem` in Haskell: (When is the difference between quotRem and divMod useful?)[http://stackoverflow.com/a/339823/679485].

This is part of the numeric trait reforms tracked in issue #4819.
@graydon
Copy link
Contributor

graydon commented Apr 21, 2013

Does % still do the thing that is one machine instruction?

@brendanzab
Copy link
Member Author

@graydon Yes of course. / and % behave exactly like C – for compatibility and performance reasons. The only change is the name.

@graydon
Copy link
Contributor

graydon commented Apr 21, 2013

Cool, thanks!

@bors bors closed this Apr 21, 2013
@bors bors merged commit 01eb5e8 into rust-lang:incoming Apr 21, 2013
@brendanzab brendanzab deleted the rem-quot branch April 21, 2013 20:54
bors added a commit that referenced this pull request Apr 23, 2013
BigInt had been supported quot/rem and div/mod correctly, but after merging #5990 they have been broken.
This commit fixes it.
flip1995 pushed a commit to flip1995/rust that referenced this pull request Sep 10, 2020
default_trait_access: Fix wrong suggestion

rust-lang/rust-clippy#5975 (comment)
> I think the underlying problem is clippy suggests code with complete parameters, not clippy triggers this lint even for complex types. AFAIK, If code compiles with `Default::default`, it doesn't need to specify any parameters, as type inference is working. (So, in this case, `default_trait_access` should suggest `RefCell::default`.)

Fixes rust-lang#5975 Fixes rust-lang#5990

changelog: `default_trait_access`: fixed wrong suggestion
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants