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
// `d`: A reference to a fixed-size array, &[i32;5]. The compiler knows the length from the type.
100
+
// `e`: A reference to a slice, &[i32]. Since the length is not part of the type,
101
+
// it stores [address, length] at runtime, making it a fat pointer.
98
102
```
99
103
100
-
> 💡 An array of Copy types stores its data inline (store elements contiguously) wherever it is declared. It lives on the stack as a local variable, in the binary if it is `static`, or on the heap if it is wrapped in a `Box` or `Vec`.
101
-
>
102
-
> ```rust
103
-
> STACK
104
-
> [ 1, 2, 3 ] // let b: [i32; 3] = [1, 2, 3];
105
-
>
106
-
> [ ptr ] // let d = &b; 💡 pointer points to 0th index element of the array + len(3) is baked into the Type
107
-
> (ThinPtr)
108
-
>
109
-
> [ ptr, len ] // let e = &b[1..]; 💡 pointer points to 1st index element of the array
0 commit comments