Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
unrealhoang
on Dec 18, 2020
|
parent
|
context
|
favorite
| on:
A case study on strict null checks
> Can you tweak your function to stop filling the first time a zero is encountered? That's a simple one-line change with the for loop, but a puzzle for the functional iteration.
In Rust:
a.iter_mut().take_while(|i| *i == 0).for_each(|i| *i = 0)
And it's as fast as hand-written for loop.
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search:
In Rust:
And it's as fast as hand-written for loop.