tuple structs

This commit is contained in:
Tyrel Souza 2023-02-26 23:49:38 -05:00
parent 1fec9d301d
commit 099a55d642
No known key found for this signature in database
GPG Key ID: F3614B02ACBE438E
3 changed files with 27 additions and 0 deletions

7
rectangles/Cargo.lock generated Normal file
View File

@ -0,0 +1,7 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "rectangles"
version = "0.1.0"

8
rectangles/Cargo.toml Normal file
View File

@ -0,0 +1,8 @@
[package]
name = "rectangles"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]

12
rectangles/src/main.rs Normal file
View File

@ -0,0 +1,12 @@
fn main() {
let rect1 = (30, 50);
println!(
"The area of a rectangle is {} square pixels",
area(rect1)
);
}
fn area(dimensions: (u32, u32)) -> u32 {
dimensions.0 * dimensions.1
}