Playground

The Rust Playground provides an easy way to run short Rust programs, and is the basis for the examples and exercises in this course. Try running the “hello-world” program it starts with. It comes with a few handy features:

  • 在 “Tools” 下,使用 rustfmt 选项以 “standard” 方式设置代码格式。

  • Rust 具有两个用于生成代码的主要 “配置文件”:调试(进行额外运行时检查、较少优化)和发布(较少运行时检查,进行大量优化)。可以在顶部的 “Debug” 下访问这些内容。

  • 如果感兴趣,您可以使用 “…” 下的 “ASM” 查看生成的汇编代码。

This slide should take about 2 minutes.

As students head into the break, encourage them to open up the playground and experiment a little. Encourage them to keep the tab open and try things out during the rest of the course. This is particularly helpful for advanced students who want to know more about Rust’s optimizations or generated assembly.