Pranshu Rastogi pfp
Pranshu Rastogi

@pranshurastogi

#Day3ofRust Why indexing a list have usize as type - usize is Rust's pointer sized unsigned integer type. Here's what that means: Size depends on your system: -- On 64-bit systems: usize = 64 bits (0 to 18,446,744,073,709,551,615) -- On 32-bit systems: usize = 32 bits (0 to 4,294,967,295) It automatically matches your CPU architecture. Why does it exist? Rust needs a type that can represent any valid memory address or collection size on your system. Using a fixed-size type like u32 would fail on 64-bit systems where addresses can be larger.
0 reply
0 recast
0 reaction