mirror of
https://github.com/nkbai/book.git
synced 2026-09-04 05:32:47 +08:00
Update src/c-tips/c-tips.md
Co-Authored-By: adamgreig <adam@adamgreig.com>
This commit is contained in:
@@ -162,7 +162,7 @@ for(i=0; i<sizeof(arr)/sizeof(arr[0]); i++) {
|
||||
|
||||
In Rust this is an anti-pattern: indexed access can be slower (as it needs to
|
||||
be bounds checked) and may prevent various compiler optimisations.
|
||||
|
||||
It is important to see this distinction in Rust vs C, as Rust needs to check for out-of-bounds access when manually indexing an array to guarantee memory safety, while C will happily index outside the array if given an index that will do so.
|
||||
Instead, use iterators:
|
||||
|
||||
```rust
|
||||
|
||||
Reference in New Issue
Block a user