RustViz: Interactively Visualizing Ownership and Borrowing
Marcelo Almeida, Grant Cole, Ke Du, Gongming Luo, Shulin Pan, Yu Pan, Kai Qiu, Vishnu Reddy, Haochen Zhang, Yingying Zhu, Cyrus Omar · 2022
Rust is an industrial systems programming language unique in achieving memory safety without the need for a garbage collector. Instead, Rust relies on a unique and sometimes subtle resource ownership and borrowing system. This system can make learning Rust a challenge, even for experienced programmers. Motivated by these challenges, we introduce RustViz, a tool that allows an instructor to generate custom interactive timelines depicting ownership and borrowing events alongside Rust code examples embedded within learning material. These visualizations makes visible the static events, and subsequent state changes, that a Rust programmer must otherwise track entirely mentally. We have used RustViz to build a week-long Rust unit in a large undergraduate programming languages course. We demonstrate that this learning material, and the RustViz visualizations in particular, were valuable to students and led to the development of an accurate mental model of the essentials of ownership and borrowing in Rust.