Rust
Rust 1.85

Run Rust Online

Execute Rust code instantly in a secure, isolated sandbox. No setup, no installs — just write and run.

main.rs
Output
Click "Run Code" to execute...

About Rust

Rust is a systems language designed for safety and speed without a garbage collector. It powers performance-critical systems at Discord, Cloudflare, and Dropbox. The borrow checker eliminates entire classes of memory bugs at compile time.

Our sandbox runs Rust 1.85 with the standard library. cargo package install is available in Pro+ sessions.

Sandbox Features

  • Secure execution with Docker + gVisor isolation
  • Rust 1.85 with standard library
  • Up to 600s execution time (Mega tier)
  • Stdin, expected_output, command_line_arguments
  • Stateful sessions and package install (Pro+)
  • REST API for programmatic access

Use Rust with stateful sessions

Open a session once, then call execute repeatedly — variables, files, and installed packages persist between runs. Perfect for code interpreters and REPL-style agents.

# 1. Create a session
curl -X POST https://api.sandboxapi.dev/v1/sessions \
  -H "X-RapidAPI-Key: $KEY" \
  -d '{"language":"rust","idle_ttl":300}'
# → {"id":"sess_abc","language":"rust",...}

# 2. Execute — first call
curl -X POST https://api.sandboxapi.dev/v1/sessions/sess_abc/execute \
  -H "X-RapidAPI-Key: $KEY" \
  -d '{"code":"let x = 42; println!(\"{}\", x);"}'

# 3. Execute again — state carries over
curl -X POST https://api.sandboxapi.dev/v1/sessions/sess_abc/execute \
  -H "X-RapidAPI-Key: $KEY" \
  -d '{"code":"// Note: Rust is compiled — sessions persist files, not REPL state"}'

Note: Rust is a compiled language. Sessions persist installed packages and files on disk, but variable state does not carry between calls. Use multi-file submissions or write intermediate state to disk.

Read the sessions docs →

Run Code in Other Languages

Need More? Get API Access

Integrate secure code execution into your own apps with our REST API. Free tier includes 500 executions per month.

Get API Key on RapidAPI