Online Rust Compiler
Compile and run Rust online with rustc 1.99 in the 2024 edition. Press Run and your program is built and started, with rustc's errors and suggestions shown next to the editor if the build fails. Programs can read input from stdin as they run, and use the whole standard library.
How to run Rust code online
- This page opens with Rust selected, so you can start typing straight away.
- Write your code in the editor, or open files from your computer: single files, or a whole project as a .zip.
- Press Run, or Ctrl+Enter. The output appears in the panel beside the editor, and when the program asks for input you type it there and press Enter.
- Share a copy with a link, or save your files to your computer.
Rust 1.99 on Online IDE
- Your code is built with rustc in the 2024 edition, and the program starts as soon as the build succeeds.
- Compiler errors appear in the output panel with the file name, the line and rustc's suggestion.
- Read a line with std::io::stdin().read_line and type it in the output panel. print! shows its text only after a flush, so call io::stdout().flush() before asking.
- Only the standard library is available: programs cannot download crates, so Cargo dependencies do not work.
Example: a Rust program that reads input
use std::io::{self, Write};
fn main() {
print!("Enter a number: ");
io::stdout().flush().unwrap();
let mut line = String::new();
io::stdin().read_line(&mut line).unwrap();
match line.trim().parse::<i64>() {
Ok(n) => println!("{} squared is {}", n, n * n),
Err(_) => println!("That is not a whole number."),
}
}
Features of this tool
- Simple and fastA clean, lightweight editor that opens instantly.
- Powered by AceThe Ace code editor, with syntax highlighting, autocompletion and bracket matching.
- Interactive programsType input into the terminal while your program runs.
- Several filesWork in tabs, open files or a .zip from your computer, and save the project back to disk.
- Made for learningHelpful for beginners to learn and practice programs.
- Light and dark themesPlus 39 editor themes, a choice of coding fonts, and Vim, Emacs or VS Code keys.
- Keep your outputCopy or download the program output in one click.
- Share by linkSave your code in the cloud and open it anywhere.
Frequently asked questions
Which Rust version does Online IDE use?
Rust 1.99, compiled with rustc in the 2024 edition, on Linux.
Can I use crates from crates.io?
No. Only the standard library is available, because programs have no network access to download anything.
Why does my prompt appear after I type?
print! does not end the line, and Rust holds the text until a newline or a flush. Call io::stdout().flush() after print!, or use println!.
Can a Rust program read input?
Yes. Use io::stdin().read_line, then type into the output panel while the program waits and press Enter.
Contact us
For any feedback, queries or issues, please feel free to contact us or write to . We value your input and are committed to providing the best possible experience for our users.