Hacker News new | ask | show | jobs
by half-kh-hacker 1198 days ago
the docs[0] are clear:

> be careful: if you try to access an index which isn’t in the Vec, your software will panic!

> Use get() and get_mut() if you want to check whether the index is in the Vec.

In my experience, most people are using get() if the source of the index is untrusted

[0]: https://doc.rust-lang.org/std/vec/struct.Vec.html#indexing

1 comments

A lot of these Rust complaints are just people not reading the docs (not trying to say Rust doesn't have legitimate usage friction; of course it does).

Pro tip: most popular crates have excellent documentation (I know it's a shocker coming from other languages). So, check stuff before you use it.

I assume this is because the ecosystem lowers the barrier to entry for writing an generating documentation (compared to other ecosystems).

I wasn’t complaining about anything. I was simply giving an example of a library that behaves in this way.