Skip to content

Generalize the few functions that are not common across all the core integer modules #2239

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

Closed
brson opened this issue Apr 19, 2012 · 4 comments
Labels
C-cleanup Category: PRs that clean code up or issues documenting cleanup. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.

Comments

@brson
Copy link
Contributor

brson commented Apr 19, 2012

The uint/int/i8 etc modules mostly share the same code but there are a few functions that are still specific to a single module. It should be possible to move these to the int-template or uint-template module as appropriate so they can be used for all integer types.

These are they:

  • int::{ hash, parse_buf, from_str, to_str, str, pow }
  • uint::{ div_ceil, div_round, div_floor, hash, iterate }
  • uint::{ next_power_of_two, parse_buf, from_str, to_str, str }
  • u64::{ to_str, str, from_str }
@graydon
Copy link
Contributor

graydon commented Aug 8, 2012

This feels nearly-done to me, you agree?

@Aatch
Copy link
Contributor

Aatch commented Jun 7, 2013

Is this done now? With the extensive re-working of std::num we don't even have [u]int-template any more.

@thestinger
Copy link
Contributor

Instead of the template we have macros generating non-generic functions now.

@thestinger
Copy link
Contributor

There's no longer a lack of code reuse, but definitely a lack of generic functions rather than generated code. These are often very hard to write without missing corner cases, so they can be tackled individually.

bors added a commit to rust-lang-ci/rust that referenced this issue Sep 22, 2022
BoxyUwU pushed a commit to BoxyUwU/rust that referenced this issue Feb 11, 2025
Checkout repository sources in rustc-pull CI action
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. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
Projects
None yet
Development

No branches or pull requests

4 participants