Rust is a systems programming language
that runs blazingly fast,
prevents almost all crashes*,
and eliminates data races.
Show me more!
fn main() { // A simple integer calculator: // `+` or `-` means add/sub by 1 // `*` or `/` means mul/div by 2 let program = "+ + * - /"; let mut accumulator = 0; for token in program.chars() { match token { '+' => accumulator += 1, '-' => accumulator -= 1, '*' => accumulator *= 2, '/' => accumulator /= 2, _ => { /* ignore everything else */ } } } println!("The program \"{}\" calculates the value {}", program, accumulator); }
* In theory. Rust is a work-in-progress and may do anything it likes up to and including eating your laundry.