Pybites Logo Rust Platform

Fighting the Borrow Checker

Medium +3 pts

In Python, you can freely mix reading and modifying data:

items = [1, 2, 3] first = items[0] # read items.append(4) # modify while holding reference print(first) # works fine... usually # But this can cause subtle bugs: d = {"key": [1, 2]} ref = d["key"] # reference to the list d["key"] = [99] # replace the list ref.append(3) # ref still points to old list!

Python catches some issues at runtime, but many aliasing bugs silently corrupt …

Login to see the full exercise.