This is a Rust starter repository that has been set up to be a quick start for making a new Rust project using vscode as your editor.
Setting this up should give you a Rust project that has the following features for vscode
- error highlighting
- breakpoint debugging
- compilation and running in vscode debug console via vscode launch options &
F5
This has only been tested on OSX, any Linux or Windows specifics might be different.
- install rust rust-lang site
- Make sure to add
source $HOME/.cargo/envto your.zshrcif you usezshor else the build task won't findcargo
- Make sure to add
- install rust language server (RLS) see most recent instructions here
rustup updaterustup component add rls rust-analysis rust-src rustfmtrustfmtwas added extra fromrust-lang/rlsrequirements
- install the rust vscode extension rls-vscode
- For OSX/Linux install CodeLLB extension (used for debugging rust code inside vscode)
- I believe Windows will need C/C++ instead
- Open vscode and select
File -> Open Workspacethen navigate into{location of this repo}/.vscode/and selectworkspace.code-workspace- If you are on mac and cannot see dot files / folders in the explorer press
shift+cmd+.and they should show up - If VSCode doesn't suggest plugins automatically check out the recommended extensions in
worspace.code-workspace
- If you are on mac and cannot see dot files / folders in the explorer press
At this point you are all set to be able to debug! Either nvaigate to the debug panel in vscode and press the play button at the top. Or press F5 to compile and run.
Try setting a breakpoint just inside the main function and press F5 to build and execute to ensure that you have everything working.
Check out the Branches section to see examples and setups doing different things
After you have everything set up you might want to rename everything from rust_starter to your project name.
Easiest way is to do a global search for rust_starter but mainly look in the following
- Cargo.lock
- Cargo.toml
- launch.json
- Make a debug docker container version of this so people don't have to install rust on their machine if they don't want
- master - This branch, helps set up the most basic rust project with no special cargo dependencies
- rocket-REST - A very simple single HTTP GET API done with Rocket
- todo-REST - Shows a basic todo REST api done with Rocket