-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Audit integer types in the standard library #22240
Comments
Nominating for the 1.0 beta milestone. |
I'll finish up collections. Looks like I just missed some docs stuff. |
1.0 beta, P-backcompat-lib. |
cc @nick29581 @pnkfelix @aturon @alexcrichton @pcwalton @steveklabnik @wycats don't forget to sign up for somethin' ;) |
I'll take libunicode, char, str and ascii |
@nikomatsakis some of the uses of I sympathize with not wanting to jump into fully generic code in these examples. But for consistency in the docs overall, what do we want our go-to type to be in these cases: |
Yes, my general rule when updating the docs is to try to have integer-fallback trigger and have i32 inferred, with explicit i32 when necessary. So e.g. I use a lot of |
Some function signatures have changed, so this is a [breaking-change]. In particular, radixes and numerical values of digits are represented by `u32` now. Part of rust-lang#22240
EDIT: Anyway, once #19284 is fixed, |
* count_ones/zeros, trailing_ones/zeros return u32, not usize * rotate_left/right take u32, not usize * RADIX, MANTISSA_DIGITS, DIGITS, BITS, BYTES are u32, not usize Doesn't touch pow because there's another PR for it. cc rust-lang#22240 r? @gankro
May I take the remaining |
… r=alexcrichton Integer audit in `libstd/thread_local/*`, part of rust-lang#22240
…e, r=Manishearth Part of rust-lang#22240.
Seems like it's time for someone to just finish all that remains in one fell swoop. |
Everything has been taken already, no ? |
@GuillaumeGomez Looks like it. |
@GuillaumeGomez yes I suppose you are correct, but there are several with no listed PR, all assigned to you or @vojtechkral, can you guys attest that those are in the pipeline now? I can't quite tell from all the various citations appearing everywhere. |
All attributed to me have been merged. |
Mine too. |
Great, thanks to you both! |
Below is a list of modules that contain text matching the regular expression
\bu?int\b
and which are intended to be stable. In some cases, these terms only appear in comments (which should still be fixed). In some cases, I have simply put..
after a directory to indicate all files within that directory. Please sign up for modules in comments below and I will endeavor to keep this list up to date with who is working on what (if you have sufficient privileges, feel free to edit the comment directly).Guidelines to follow
These are the guidelines that we intend to follow in the standard library. These guidelines are not intended as universal guidelines to be used outside the standard library (though of course one might choose to do so).
usize
orisize
.write_u16
would take au16
argument.i32/u32
if the value has a narrow range andi64/u64
otherwise.Examples:
usize
.u64
, as the maximum size of a file is not tied to addressable memory.write_u16
takes au16
(shocker, I know!)u32
.u8
, since a radix higher than 256 is not useful, but the domain of useful radices is actually much smaller thanu8
, so usingu8
isn't providing a meaningful guarantee, and will simply increase friction.Module listing
mem
,nonzero
, andcell
modules for proper integer usage #22401option
andptr
types for proper integer usage #22294option
andptr
types for proper integer usage #22294option
andptr
types for proper integer usage #22294borrow
,cmp
,default
, andintrinsics
modules for proper integer usage #22485option
andptr
types for proper integer usage #22294borrow
,cmp
,default
, andintrinsics
modules for proper integer usage #22485option
andptr
types for proper integer usage #22294borrow
,cmp
,default
, andintrinsics
modules for proper integer usage #22485mem
,nonzero
, andcell
modules for proper integer usage #22401mem
,nonzero
, andcell
modules for proper integer usage #22401borrow
,cmp
,default
, andintrinsics
modules for proper integer usage #22485libstd/sys/common/..- not publiclibstd/sys/windows/..- not publiclibstd/sys/unix/..- not publiclibstd/os.rs- will be#[deprecated]
libstd/io/buffered.rs- will be#[deprecated]
The text was updated successfully, but these errors were encountered: