Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
masklinn
on March 21, 2020
|
parent
|
context
|
favorite
| on:
Secure Rust Guidelines
> In practice, you don't really need one - the safe alternative to "xs !! n" is pattern-matching on the result of "drop n xs", as that's [] if xs has ≤n elements:
Great so instead of `xs !! n` you're supposed to write
case drop n xs of [] -> … x :: _ -> …
that seems… less than likely?
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search:
Great so instead of `xs !! n` you're supposed to write
that seems… less than likely?