How to create a function in Rust

2 Answers

0 votes
fn square(x : u32) -> u32 { x * x }

fn main() {
    let x = 10;

    println!("{}", square(x));
}



/*
run:

100

*/

 



answered Dec 20, 2022 by avibootz
0 votes
fn main() {
    your_function();
}

fn your_function() {
    println!("RUST");
}



/*
run:

RUST

*/

 



answered Dec 20, 2022 by avibootz
...