RustRover 2024.3 Help

Rust REPL console

REPL console is an interactive read-eval-print-loop environment for prototyping and testing your Rust code. This handy tool is a notebook, a calculator, and a Rust interpreter all in one.

Implemented on top of the evcxr_repl utility, Rust REPL provides syntax highlighting and completion for the code lines you type. It also shows a pane with the list of variables, functions, and structures currently in use.

You can access the REPL console from the context menu (Rust | Rust REPL), run it from the main menu (Tools | Rust | Rust REPL), or look it up in the Search Everywhere dialog (double Shift).

REPL in the Search Everywhere dialog

Find below an example of how the REPL console can be used to draft a simple program in Rust:

Example of using Rust REPL

The REPL console has the following controls:

  • Rerun – click to terminate the current REPL session and restart the console.

  • Execute Current Statement in One-Line Console – click to run the code you have written in the REPL console.

  • Stop Rust REPL – click to stop Rust REPL.

  • Close – click to close the REPL console.

  • Soft-Wrap – click to create soft wraps in the message text.

  • Scroll to End – click to scroll to the end of displayed messages.

  • Print – click to print console text.

  • Browse Query History – click to view the history of entered queries.

  • Show Variables – click enable or disable the variables panel.

Command reference

Add dependencies

To add an external crate, use the :dep command followed by the crate name. For example:

:dep rand

This downloads and compiles the latest version of the specified crate. If you want to download a specific version, include it as follows:

:dep rand = "0.8.5"

Use the crate

Once the crate has been added, you can utilize it in your code using the use command:

use rand::Rng; let mut rng = rand::thread_rng(); let random_number: u32 = rng.gen_range(1..=10); println!("Random number: {}", random_number);

List all commands

To get the list of all available commands, type :help.

Last modified: 23 January 2025