A Rust REPL (Read-Eval-Print loop) using the evcxr evaluation context (An implementation of eval() for Rust).
Why?
A REPL is an great tool for coding, learning, debugging, and experimenting. It shortens the feedback loop by providing a live interactive programming environment, boosts productivity, and enhances understanding of your code or language.
How?
Installation
Download a local copy of the Rust source (if you haven’t already)
rustup component add rust-src
Info
If it’s already downloaded you will get a message like:
$ rustup component add rust-srcinfo: component 'rust-src' is up to date
Install
cargo install --locked evcxr_repl
Usage
Starting the REPL
evcxr
Example
❯ evcxrWelcome to evcxr. For help, type :help>
Using the REPL (Available Commands)
>> :help:allow_static_linking Set whether to allow static linking of dependencies (0/1):build_env Set environment variables when building code (key=value):cache Set cache size in MiB, or 0 to disable.:clear Clear all state, keeping compilation cache:clear_cache Clear the cache used by the :cache command:codegen_backend Set/print the codegen backend. Requires nightly:dep Add dependency. e.g. :dep regex = "1.0":doc show the documentation of a variable, keyword, type or module:efmt Set the formatter for errors returned by ?:env Set an environment variable (key=value):explain Print explanation of last error:fmt Set output formatter (default: {:?}):help Print command help:internal_debug Toggle various internal debugging code:last_compile_dir Print the directory in which we last compiled:last_error_json Print the last compilation error as JSON (for debugging):linker Set/print linker. Supported: system, lld, mold:load_config Reloads startup configuration files. Accepts optional flag `--quiet` to suppress logging.:offline Set offline mode when invoking cargo (0/1):opt Set optimization level (0/1/2):preserve_vars_on_panic Try to keep vars on panic (0/1):quit Quit evaluation and exit:restart Restart child process:sccache Set whether to use sccache (0/1).:show_deps Show the current dependencies:t Short version of :type:time_passes Toggle printing of rustc pass times (requires nightly):timing Toggle printing of how long evaluations take:toolchain Set which toolchain to use (e.g. nightly):type Show variable type:types Toggle printing of types:vars List bound variables and their types:version Print Evcxr version