Closed
Description
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
orisize
. - 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 au16
argument. - Otherwise, use
i32/u32
if the value has a narrow range andi64/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 au16
(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 thanu8
, so usingu8
isn't providing a meaningful guarantee, and will simply increase friction.
- You might expect
Module listing
- libcollections/.. -- Gankro
- libcore/mem.rs -- @pnkfelix Audit core
mem
,nonzero
, andcell
modules for proper integer usage #22401 - libcore/ops.rs -- @nikomatsakis Audit the
option
andptr
types for proper integer usage #22294 - libcore/result.rs -- @nikomatsakis Audit the
option
andptr
types for proper integer usage #22294 - libcore/finally.rs -- @nikomatsakis Audit the
option
andptr
types for proper integer usage #22294 - libcore/marker.rs -- @nikomatsakis (no ints/uints)
- libcore/borrow.rs -- @pnkfelix Audit core
borrow
,cmp
,default
, andintrinsics
modules for proper integer usage #22485 - libcore/fmt/.. @nick29581 int audit core::{hash, fmt}, std::sync #22700
- libcore/char.rs -- petrochenkov Audit integer types in libunicode, libcore/(char, str) and libstd/ascii #22339
- libcore/option.rs -- @nikomatsakis Audit the
option
andptr
types for proper integer usage #22294 - libcore/default.rs -- @pnkfelix Audit core
borrow
,cmp
,default
, andintrinsics
modules for proper integer usage #22485 - libcore/ptr.rs -- @nikomatsakis Audit the
option
andptr
types for proper integer usage #22294 - libcore/clone.rs @brson ok. no use of ints
- libcore/cmp.rs -- @pnkfelix Audit core
borrow
,cmp
,default
, andintrinsics
modules for proper integer usage #22485 - libcore/str/.. -- petrochenkov Audit integer types in libunicode, libcore/(char, str) and libstd/ascii #22339
- libcore/nonzero.rs -- @pnkfelix Audit core
mem
,nonzero
, andcell
modules for proper integer usage #22401 - libcore/cell.rs -- @pnkfelix Audit core
mem
,nonzero
, andcell
modules for proper integer usage #22401 - libcore/intrinsics.rs -- @pnkfelix Audit core
borrow
,cmp
,default
, andintrinsics
modules for proper integer usage #22485 - libcore/num/.. @brson core: Audit num module for int/uint #22600 pow is covered by Make Int::pow() take exp as u32 instead usize #22087
- libcore/lib.rs @GuillaumeGomez
- libcore/atomic.rs @brson. ok. everything is ptr size. bool is implemented as usize, but intentionally.
- libcore/hash/.. @nick29581 int audit core::{hash, fmt}, std::sync #22700
- libcore/panicking.rs @GuillaumeGomez Replace uint by usize in libcore/panicking.rs #22507
- libcore/macros.rs fixed by Change column!() / line!() return type from usize to u32. #19284 #21769 (@nick29581 (not my patch though))
- libcore/raw.rs @brson. ok. one usize representing slice length
- libcore/slice.rs @brson. ok. all usizes for indexes or ranges
-
libstd/sys/common/..- not public -
libstd/sys/windows/..- not public -
libstd/sys/unix/..- not public - libstd/collections/mod.rs -- Gankro
- libstd/ascii.rs -- petrochenkov Audit integer types in libunicode, libcore/(char, str) and libstd/ascii #22339
- libstd/thread.rs -- @GuillaumeGomez
-
libstd/os.rs- will be#[deprecated]
- libstd/num/.. @gankro
- libstd/lib.rs -- @GuillaumeGomez
- libstd/thread_local/.. -- @vojtechkral
- libstd/failure.rs -- file no longer exists
-
libstd/io/buffered.rs- will be#[deprecated]
- libstd/sync/.. @nick29581 int audit core::{hash, fmt}, std::sync #22700
- libunicode/.. Audit integer types in libunicode, libcore/(char, str) and libstd/ascii #22339