Rust questions, answered

Short answers from the Ruststudio team to the questions Rust developers ask most: getting started, the borrow checker, cargo, debugging and choosing a framework.

Updated · describes Ruststudio 0.1.7

Answers from the Ruststudio team to the questions Rust developers ask most. Ask your own in the community forum.

Frequently asked questions

Something else? Ask in the community forum or send feedback.

How do I get started with Rust?

Install the toolchain with rustup, which gives you rustc, cargo and the standard library. Create a project with cargo new hello, run it with cargo run, and read The Rust Programming Language, the free official book. In Ruststudio, New Project does the cargo new for you and F5 runs it.

What is the difference between rustup, cargo and rustc?

rustc is the compiler. cargo is the build tool and package manager that calls rustc, downloads crates and runs tests. rustup installs and switches Rust versions (stable, beta, nightly) and components such as rust-analyzer, clippy and rustfmt.

Why does the borrow checker say a value was moved?

Rust gives each value one owner. Passing a non-Copy value to a function or assigning it moves it, and the old name can no longer be used. Borrow it with & instead, call .clone() if you need a second copy, or change the function to take a reference.

Should I use String or &str?

Use &str for text you only read, such as function parameters, and String for text you own and may change or return. A &str can be made from a String with &s, and a String from a &str with .to_string() or String::from.

How do I debug a Rust program?

Build in debug mode and run under a debugger such as lldb or gdb to set breakpoints and inspect variables. In Ruststudio press F9 on a line, then F5, and step with F10 and F11. println! and dbg! are fine for quick checks.

What does cargo check do, and when should I use it?

cargo check compiles your code to find errors without producing a program, so it is much faster than cargo build. Use it while you write; use cargo build or cargo run when you need to run the result.

How do I add a dependency?

Run cargo add name, or add the crate to the [dependencies] section of Cargo.toml. Find crates on crates.io. In Ruststudio, the rupm and crates.io view adds a crate for you, and the database connectors add a driver with a working example.

Why is my Rust build slow, and why is the target folder huge?

The first build compiles every dependency, and Cargo keeps separate builds for each profile and dependency version. Use cargo check while editing, build release only when needed, and clear old target folders with cargo clean or the Cargo Cleaner.

Which Rust web framework should I learn first?

axum is a good first choice for a back end: it is built on tokio, widely used and well documented. Our web frameworks guide compares it with Actix Web, Rocket, Leptos and Yew.

Can I write Android or desktop apps in Rust?

Yes. egui and Slint draw native windows on desktop and Android, and Tauri puts a web interface in a Rust shell. The GUI frameworks guide compares them and says which to start with.

Where can I ask a question that is not about Ruststudio?

Here. The forum is for Rust questions in general as well as for Ruststudio. Check the user guide first, then start a thread in the Help category with what you tried, what you expected and the exact error text.

Where is the official Rust forum?

The official Rust users forum is users.rust-lang.org, run by the Rust project; language design is discussed on internals.rust-lang.org. This page is the Ruststudio community forum, a separate place for questions about the IDE and about Rust in general.

Is this the forum for the game Rust?

No. This forum is about the Rust programming language and the Ruststudio IDE.

Do I need an account to read the forum?

No. Anyone can read. A free account, with your e-mail address and a 6-digit code, lets you post and reply.