Slacker News Slacker News logo featuring a lazy sloth with a folded newspaper hat
  • top
  • new
  • show
  • ask
  • jobs
Library

Comment by stub_out

6 hours ago

C++ developers constantly wrestle with `vector` iterator invalidations. Good on Zig for making this a first-class concern.

2 comments

stub_out

Reply

brcmthrowaway  5 hours ago

How does Rust avoid this?

  • trucks-refinish  5 hours ago

    In rust you cannot mutate anything that is being read basically. The borrow checker enforces this.

    So an iterator takes an immutable reference to the vector and mutation requires a mut ref, and you can't have both at the same time.

Slacker News

Product

  • API Reference
  • Hacker News RSS
  • Source on GitHub

Community

  • Support Ukraine
  • Equal Justice Initiative
  • GiveWell Charities