Rust
About 323 wordsAbout 1 min
2025-10-08
Overview
The theme provides Rust code demonstration functionality, supporting online execution of Rust code.
Important
This functionality works by submitting code to a server for compilation and execution, and only a single code file can be submitted at a time.
Therefore, please do not use this feature to execute overly complex code, and avoid making execution requests too frequently.
Configuration
This feature is disabled by default. You can enable it through configuration.
export default defineUserConfig({
theme: plumeTheme({
markdown: {
repl: {
rust: true,
},
},
})
})
Usage
Use the ::: rust-repl
container syntax to wrap Rust code blocks. The theme will detect the code blocks and add execution buttons.
Read-only Code Demo
Rust code demos are read-only by default and cannot be edited.
::: rust-repl title="Custom Title"
```rust
// your rust code
```
:::
Editable Code Demo
For online editing and execution, wrap the code block in the ::: rust-repl editable
container syntax.
::: rust-repl editable title="Custom Title"
```rust
// your rust code
```
:::
Examples
Print Content
Input:
::: rust-repl title="Print Content"
```rust
fn main() {
println!("Hello, world!");
}
```
:::
Output:
Print Content
fn main() {
println!("Hello, world!");
}
Click the Execute button to run the code.
Print Error Information
Input:
::: rust-repl
```rust
fn main() {
printlnl!("Hello, world!");
}
```
:::
Output:
rust playground
fn main() {
printlnl!("Hello, world!");
}
Wait for Child Process Execution
Input:
::: rust-repl
```rust
use std::process::Command;
fn main() {
let mut child = Command::new("sleep").arg("5").spawn().unwrap();
let _result = child.wait().unwrap();
println!("reached end of main");
}
```
:::
Output:
rust playground
use std::process::Command;
fn main() {
let mut child = Command::new("sleep").arg("5").spawn().unwrap();
let _result = child.wait().unwrap();
println!("reached end of main");
}
Editable Demo
Input:
::: rust-repl editable
```rust
fn main() {
println!("Hello, world!");
}
```
:::
Output:
rust playground
fn main() {
println!("Hello, world!");
}
Contributors
Changelog
38505
-docs: update en docs (#708)on4d236
-feat(theme)!: add collections support (#704)onb0742
-refactor(plugin-md-power): improve md plugins (#562)on0fd6c
-refactor(theme): improve types and flat config (#524)on607aa
-fix(docs): incorrect rust icon display in dark modeon5addb
-feat(plugin-md-power): 支持可编辑的代码演示on428b8
-docs: update code online repl docon