Skip to content

Commit d90578f

Browse files
committed
Minor edit
1 parent 3d63960 commit d90578f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

07_arrays_and_conversions.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ We'll get a compiler error:
1818
expected `[u8; 4]`, found `&[u8]`
1919
```
2020

21-
If we look at the `from_le_bytes` method in the documentation and look at the function signature, we'll see that the parameter expected is of the type `[u8; 4]`.
21+
If we look at the `from_le_bytes` method in the documentation and check the function signature, we'll see that the parameter expected is of the type `[u8; 4]`.
2222
However, we're passing in a slice `&[u8]`.
2323
What is the difference between these two?
2424

2525
Well, in Rust, the data type `[T; N]` where `T` is any type and `N` is the number of elements, is called an *array*.
2626
Now we have to be careful because this is not the same as an array in other languages, such as Javascript and it's not the same as a list in Python.
2727
An array here is a fixed size collection that is stored on the stack as opposed to the heap.
28-
This means the data is available directly at runtime and no memory lookup is required to retrieve the data.
28+
This means the data is available more efficiently at runtime as there is no need to lookup that data on the heap with the use of a pointer.
2929
An array's size is constant, cannot be changed and must be known and defined at compile time.
3030

3131
So the method `from_le_bytes` only works with arrays, which makes sense.

0 commit comments

Comments
 (0)