XCODX |

Rust Online Compiler & Interpreter

Select Language
Online Code Compiler
Full HTML IDE
Py main.py
Program Output Ready
  Welcome to XCODX Online Compiler

  Quick Start:
  Ctrl+Enter  Run code
  Ctrl+S      Save / Download
  Ctrl+L      Clear output

  Select a language and start coding.
Success
Operation completed

About Rust

Rust has been voted the most admired language in Stack Overflow's developer survey for nearly a decade running, and the reason is its core bargain: memory safety without a garbage collector, enforced at compile time by the borrow checker. AWS, Microsoft, and Discord ship Rust in production, and it became the first language after C to be accepted into the Linux kernel. Its compiler errors are famously helpful teachers. This page compiles your code with a recent stable rustc and runs the binary in a live terminal — stdin().read_line() blocks for genuine keyboard input — so you can wrestle with ownership from any browser, no rustup required.

Hello World in Rust

use std::io::{self, Write};

fn main() {
    print!("Enter a temperature in Fahrenheit: ");
    io::stdout().flush().unwrap();

    let mut line = String::new();
    io::stdin().read_line(&mut line).expect("failed to read line");
    let f: f64 = line.trim().parse().expect("please type a number");

    let c = (f - 32.0) * 5.0 / 9.0;

    let verdict = match c {
        t if t < 0.0 => "below freezing!",
        t if t > 30.0 => "properly hot!",
        _ => "comfortable.",
    };

    println!("{f}\u{00b0}F = {c:.1}\u{00b0}C \u{2014} {verdict}");
}

When to use Rust

Fight the borrow checker in short, low-stakes rounds — the proven way to internalize ownership, borrowing, and lifetimes — by running Rustlings-style drills with instant compiler feedback. Solve LeetCode problems in Rust to stand out in systems and blockchain interviews, verify how iterators chain with map, filter, and collect, or check whether a match expression covers every variant of your enum. Developers arriving from C++ or Go can port a familiar exercise here and let rustc's error messages narrate the differences.

Common questions

Can Rust programs read stdin interactively on this page?

Yes — the compiled binary runs in a real terminal session, so io::stdin().read_line() waits for you to type. One tip: print! doesn't flush automatically, so call io::stdout().flush() after a prompt (as our example does) to make sure the prompt text appears before the program blocks for input.

Which Rust toolchain compiles my code?

A recent stable rustc, so idiomatic modern Rust — the ? operator, inline format arguments like println!("{name}"), if let chains from stable releases, and the standard iterator adapters — compiles as expected. Nightly-only features behind #![feature] gates won't build; the compiler error will identify them right away.

Are crates like rand, serde, or tokio available?

No — there's no cargo and no network fetch in the sandbox, so external crates can't be used. The std library alone is deep enough for practice: collections (Vec, HashMap, BTreeMap), threads and channels from std::thread and std::sync::mpsc, string handling, and file-free I/O all work out of the box.

How Rust runs on XCODX

Sandbox filename
main.rs
Entry point
single main source file
Editor grammar
rust
Reading stdin
io::stdin().read_line()
Input delivery
live WebSocket stream
Prompt flushing
unbuffered automatically (print! macro-shadowed to flush is prepended on live runs)
Compile limit
10 s
Run limit
3 s batch · up to 3 min live
Memory
256 MB per stage
Max source
50,000 characters

Default program on this page

fn main() {
    println!("Hello from Rust!");
    println!("Welcome to XCODX Online Compiler!");
}