Skip to content
EN

Rust Playground Demo

Interactive demo, multiple editable Rust playgrounds on one page via play.rust-lang.org.

Updated View as Markdown

1. Hello, World!

Hello World

Try editing println! to print your name and hit Run.

2. With variables and mutability

Variables & Mutability

3. Second example on same page — proves multiple embeds work

Second Example — Loops

4. Error handling — see compiler output

Try running, then fix the error and run again.

Compilation Error Demo
Fix Me — Error

5. Nightly + 2024 edition + release mode

Nightly • 2024 • Release

6. Explicit component usage (import)

Via <RustPlayground> Component

Static code stays static

This block is plain ````rustwithoutplayground` — it remains a highlighted, non-runnable code block:

fn main() {
    println!("This one is static — no Run button");
}

Fence syntax:

```rust playground title="My Example" edition=2024 channel=stable mode=debug
fn main() { println!("hi"); }
```

For MDX you can also use the component:

import { RustPlayground } from "@/components/ui/rust-playground";
<RustPlayground code={`fn main(){...}`} title="Example" />
Navigation

Type to search…

↑↓ navigate↵ selectEsc close