// SPDX-License-Identifier: MIT // Copyright (C) 2026 Pooya Parsa // Rust: the distro's rustc (Alpine's rust from main, Debian's rustc), // compiling one source file and running it, without cargo. rustc links with // the distro's gcc, which both distros' packages pull in. import type { TerminalApp } from "../types.ts"; const MAIN = `use std::thread; fn main() { println!( "Hello from Rust on {}/{}, {} CPU(s)", std::env::consts::OS, std::env::consts::ARCH, thread::available_parallelism().map_or(1, |n| n.get()) ); // A few threads, summing squares in parallel. const N: u64 = 1_000_000; const WORKERS: u64 = 4; let handles: Vec<_> = (0..WORKERS) .map(|w| thread::spawn(move || (w..N).step_by(WORKERS as usize).map(|i| i * i % 7).sum::())) .collect(); let total: u64 = handles.into_iter().map(|h| h.join().unwrap()).sum(); println!("threads done, sum: {total}"); } `; export default { id: "rust", title: "Rust", desc: "The Rust compiler, building and running a small program in the guest", // The Rust logo, from Simple Icons (CC0 1.0), slug rust. icon: { svg: '', viewBox: "-1.5 -1.5 27 27" }, colors: ["#ce422b", "#2b0f0a"], needs: { net: true }, files: { "hello.rs": MAIN, }, packages: { alpine: ["rust"], debian: ["rustc"] }, commands: ["rustc --version", "rustc hello.rs", "./hello"], } satisfies TerminalApp;