Online Rust Compiler

Write and run Rust directly in your browser.

Standard Input (optional)
Program Arguments (optional)
Output
Standard Output
Ready. Program output will appear here.
Errors
(no errors)

How to Use

  • Write a single-file Rust program with the entry function fn main().
  • Need input? Put it in the Standard Input box; it will be passed via stdin.
  • Program arguments are space-separated. For example: hello world becomes args[0]=hello and args[1]=world.
  • Click Run to compile and execute. Stdout and stderr show in the Output area.
  • Timeouts: compilation and execution each have a 2000 ms limit; keep programs concise.
  • Restrictions: no network access; runs in a sandbox. Long-running or interactive programs may be terminated.

Examples

Hello, World
fn main() {
  println!("Hello, world!");
}
Read from standard input
use std::io::{self, Read};

fn main() {
  let mut input = String::new();
  io::stdin().read_to_string(&mut input).unwrap();
  println!("Input was: {}", input.trim());
}
Try standard input: Alice
Program arguments
use std::env;

fn main() {
  for (i, a) in env::args().enumerate() {
    println!("arg[{}] = {}", i, a);
                }
                }
Try arguments: hello world