RustRover 2024.1 Help

Code generation

RustRover provides multiple ways to generate Rust code constructs and recurring elements. There are many intention actions and quick-fixes which can help you quickly insert the required code based on the current content. You can also use live templates (both custom and pre-generated), various code wrappers, postfix completion, and file templates for Cargo crates.

Generate popup

At any place in your code, call the Generate menu by pressing Alt+Insert or selecting Code | Generate from the main menu. It gives a list of the possible code generation actions, depending on the current context, caret position, or selected code:

The Generate menu

For example, you can quickly generate a setter for a struct:

Generating a setter

Creating a Cargo crate

In addition to code templates, you can use the New | Cargo Crate action to quickly add a Cargo crate into your project. RustRover will generate a directory with Cargo.toml and an src subdirectory containing main.rs.

  1. Right-click in the Project view and select New | Cargo Crate. Alternatively, call Help | Find Action (Ctrl+Shift+A) and search for Cargo Crate:

    New Cargo Crate action
  2. Specify the crate name and type:

    New crate settings
  3. The automatically generated folders and files will be placed under the project root:

    New Cargo crate generated
Last modified: 26 May 2024