- By Emmanuel Valverde
- ·
- Posted 22 Mar 2024
Advanced Katas
You have reached the highest level. You have completed the learning phases and we move on to the more complex katas. Remember that in the link of..
This post is a part of the upcoming codurance series on different ways of setting up your Rust development environment. This time it's IntelliJ.
There are lots of good options for Rust development. The classics are perhaps CLion and vim/emacs. IntelliJ has one important feature that none of these have. Refactoring. As you might expect, the refactoring tools are not as fully featured as those for Java - but they're there and nobody else has them.
cd
to parent directory you want for your projectcargo new my-project
cargo.toml
in your project root directory by following the promps in the notifications panelThere you are - you now have a functional Rust environment. With code completion, code generation, syntax highlighting, suggestions and a test runner. Everything you need to get started.
If you want your environment to do more, here are some of the tools I use to improve the work flow in Rust and IntelliJ.
cargo install rustfmt
:wa
will not trigger the reformatting - you must use the save shortcutctrl+shift+s
shortcut to ctrl+s
for more convenienceClippy is... clippy but for Rust. It will make suggestions about improvements to be made to your code. The only difference between clippy and Rust's clippy is that Rust's clippy is actually useful.
rustup toolchain install nightly
rustup run nightly cargo install clippy
cd
to root directory of your projectrustup run nightly cargo clippy
When I'm writing code - I hate having to flip to the terminal to compile and run the tests and ensure it's all good. I like to use watch tasks to continuously run my tests. Rust has an option for this.
cargo install cargo-watch
cd
to root directory of your projectcargo watch -x test
This is all well and good, but the watch tasks and clippy aren't integrated into IntelliJ, they're run separately on a terminal, and only one at a time! Well it's possible to bring them into your IDE so everything is in the same place and running together.
cargo watch -s "rustup run nightly cargo clippy && cargo test"
Now you have a Rust environment capable of
You should be aware that IntelliJ does not support Rust debugging. If that's important to you, consider using another IDE such as VSCode, CLion, vim or emacs. If you are attached to IntelliJ then you can use rust-lldb
(installed by default with rustup) from the terminal.
Any questions ? Ask on https://users.rust-lang.org/ and ping me the link to the post on Twitter or email it to me at dan.cohen@codurance.com. This way the answer will be visible to everyone in the community.
Keep on Rusting!
You have reached the highest level. You have completed the learning phases and we move on to the more complex katas. Remember that in the link of..
Our recommendation is that you first go through Object-Oriented Programming katas so that you can move on to more complex testing concepts. If so, we..
Once basic concepts such as conditionals, loops, and simple structures have been introduced and reinforced, and TDD has been strictly practiced, it's..
Join our newsletter for expert tips and inspirational case studies
Join our newsletter for expert tips and inspirational case studies