Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
exrook
on Sept 12, 2019
|
parent
|
context
|
favorite
| on:
Why is Rust slightly slower than C?
There's a similar pattern in rust:
fn loop(a: &[u8]) { assert!(a.len >= 20); for x in (0..20) { let y = a[i]; //Do something with y } }
Adding the assert before the loop will remove the bounds checks happening on each iteration.
Consider applying for YC's Summer 2026 batch! Applications are open till May 4
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search: