RustRover 2024.3 Help

Add new items to Cargo projects

RustRover makes it easy to add new items to your project, be it Cargo crates, directories, Rust files, or files with other extensions.

Creating a new item in a Cargo project

Create a new Rust file

  1. In the Project tool window (Alt+1), right-click the node in which you want to create the new file and select New | Rust File.

    Alternatively, select the necessary node, press Alt+Insert, and select Rust File.

  2. In the dialog that opens:

    • Specify the file name

    • Choose whether you want to attach the new file to the current module

    If you select Attach to module, RustRover will add the file declaration to the module's target (main.rs or lib.rs). If RustRover fails to identify the appropriate target, the file won’t be attached.

    Creating a new Rust file

If you open a Rust file that is not attached to any module, RustRover will display a banner suggesting to attach it to the current module's target.

Quick fix to attach the open Rust file to the current module

Create a Cargo crate

  1. In the Project tool window (Alt+1), right-click the node in which you want to create the new file and select New | Cargo Crate.

    Alternatively, select the necessary node, press Alt+Insert, and select Cargo Crate.

  2. Name the new crate and select its type (Binary or Library).

    Creating a new cargo crate

Create a file of an arbitrary type

  1. In the Project tool window (Alt+1), right-click the node in which you want to create a new file and click New | File.

    Alternatively, select the node, press Alt+Insert, and click File.

  2. Name the new file and specify its extension, for example: File.js, and press Enter.

Create a scratch file

  1. Go to File | New | Scratch File or press Ctrl+Alt+Shift+Insert.

  2. Select the language of the scratch file.

    Scratch files of the same type are automatically numbered and added to the Scratches and Consoles directory of the Project view.

Create a new directory

  1. In the Project tool window (Alt+1), right-click the node in which you want to create a new directory and select New | Directory.

    Alternatively, select the node, press Alt+Insert, and click Directory.

  2. Name the new directory and press Enter.

    If you want to create several nested directories, specify their names separated with slashes, for example: folder/new-folder.

    Creating a new directory
Last modified: 31 October 2024