You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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).
Use unsigned values if the value should always be greater than or equal to zero, and signed values otherwise.
For indices, pointers, or other values which are tied to a data structure whose size is proportional to the size of memory, use usize or isize.
For cases where the acceptable domain of a value perfectly fits a fixed number of bits, use the appropriate fixed-size type. For example, a method like write_u16 would take a u16 argument.
Otherwise, use i32/u32 if the value has a narrow range and i64/u64 otherwise.
Examples:
Vector indices and hashmap lengths use usize.
The size of a file would be u64, as the maximum size of a file is not tied to addressable memory.
Something like write_u16 takes a u16 (shocker, I know!)
The radix of an integer would use u32.
You might expect u8, since a radix higher than 256 is not useful, but the domain of useful radices is actually much smaller than u8, so using u8 isn't providing a meaningful guarantee, and will simply increase friction.
Below is a list of modules that contain text matching the regular expression
\bu?int\band 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).
usizeorisize.write_u16would take au16argument.i32/u32if the value has a narrow range andi64/u64otherwise.Examples:
usize.u64, as the maximum size of a file is not tied to addressable memory.write_u16takes 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 usingu8isn't providing a meaningful guarantee, and will simply increase friction.Module listing
mem,nonzero, andcellmodules for proper integer usage #22401optionandptrtypes for proper integer usage #22294optionandptrtypes for proper integer usage #22294optionandptrtypes for proper integer usage #22294borrow,cmp,default, andintrinsicsmodules for proper integer usage #22485optionandptrtypes for proper integer usage #22294borrow,cmp,default, andintrinsicsmodules for proper integer usage #22485optionandptrtypes for proper integer usage #22294borrow,cmp,default, andintrinsicsmodules for proper integer usage #22485mem,nonzero, andcellmodules for proper integer usage #22401mem,nonzero, andcellmodules for proper integer usage #22401borrow,cmp,default, andintrinsicsmodules 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]