expression

Rust Function call expressions

A call supplies inputs to callable code and can return a result. The values at the call site are arguments; names in the declaration are parameters. Expected output (not executed): 24 Why: The function receives 6 and 4 and returns their product. Common mistake: Passing only one argument to this two-parameter function is a type-checking error.

Formal Syntax & Structure

rust syntaxrust
function(argument1, argument2)

Working Example

Example Snippetrust
fn subtotal(price: i32, quantity: i32) -> i32 {    price * quantity}
fn main() {    let amount = subtotal(6, 4);    println!("{amount}");}
Rust Reference