summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2025-06-03 10:35:22 -0600
committermo khan <mo@mokhan.ca>2025-06-03 10:35:22 -0600
commitf0f8d5429747777eb46bd7a0d3b47a45567b3ce5 (patch)
treeb2c345325a09acce63cee332a8e7d8fbdabc2c2f
parentac533895fd3dfe461615363c41e33eb2af799a71 (diff)
use a tuple struct
-rw-r--r--5.2/src/main.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/5.2/src/main.rs b/5.2/src/main.rs
index 827710a..9806dda 100644
--- a/5.2/src/main.rs
+++ b/5.2/src/main.rs
@@ -41,6 +41,7 @@ fn build_user(email: String, username: String) -> User {
}
*/
+/*
fn main() {
let width1 = 30;
let height1 = 50;
@@ -54,3 +55,17 @@ fn main() {
fn area(width: u32, height: u32) -> u32 {
width * height
}
+*/
+
+fn main() {
+ let rect1 = (30, 50);
+
+ println!(
+ "The area of the rectangle is {} square pixels.",
+ area(rect1)
+ );
+}
+
+fn area(dimensions: (u32, u32)) -> u32 {
+ dimensions.0 * dimensions.1
+}