mirror of
https://github.com/compiler-explorer/compiler-explorer.git
synced 2025-12-27 14:04:04 -05:00
* Make Rust examples more idiomatic * Make 'non-idiomatic' example match the aligned version * Rename examples
17 lines
296 B
Rust
17 lines
296 B
Rust
use std::env;
|
|
|
|
const fn square(num: i32) -> i32 {
|
|
num * num
|
|
}
|
|
|
|
pub fn main() {
|
|
match env::args().nth(1).map(|r| r.parse::<i32>()) {
|
|
Some(Ok(r)) => {
|
|
println!("{}", square(r))
|
|
}
|
|
_ => {
|
|
println!("Supply a number to square")
|
|
}
|
|
}
|
|
}
|