#Day6ofRust If we declare a mutable vector v and pass it to a function, that function cannot mutate it.
- 0 replies
- 0 recasts
- 0 reactions
#day5ofRust In Rust, if the last expression in a function doesn't have a semicolon, it's implicitly returned. However, a for loop itself doesn't evaluate to a value; it's a statement that performs actions. If your function ends with a for loop, Rust sees the loop as the last "thing," and since the loop doesn't return a value, it evaluates to (), the "unit type" (similar to void in other languages).
- 0 replies
- 0 recasts
- 0 reactions
#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 replies
- 0 recasts
- 0 reactions