今天在互联网闲逛的时候无意中发现了Rustlings这个项目,刚好最近有在打算学习Rust,于是抱着试试的心态尝试了一下

安装

推荐使用官网的手动安装方法

  1. Clone官方的仓库
    1
    2
    3
    # find out the latest version at https://github.com/rust-lang/rustlings/releases/latest (on edit 5.6.1)
    git clone -b 5.6.1 --depth 1 https://github.com/rust-lang/rustlings
    cd rustings
  2. 用cargo安装
    1
    cargo install --force --path .
  3. 最后运行rustup 建议挂梯子,否则可能非常漫长
    1
    rustup update

使用

官方文档给出了具体的命令,详情查阅官网下的Doing exercises部分

  1. 在安装目录下打开终端,输入rustlings watch启动Rustlings,本人这里使用了VScode内置的终端来方便使用
  2. 根据命令行提示完成对应练习,练习用的rs文件在目录下的/exercises/文件夹内,rustlings在检测到文件变动后会自动编译检查。
  3. 完成练习后删除注释中的I AM NOT DONE来进行下一个练习

总结

目前本人只是简单完成了2、3个练习内容,后续的进度也会在博客中及时更新 大概