tuple structs
This commit is contained in:
parent
1fec9d301d
commit
099a55d642
7
rectangles/Cargo.lock
generated
Normal file
7
rectangles/Cargo.lock
generated
Normal 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
8
rectangles/Cargo.toml
Normal 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
12
rectangles/src/main.rs
Normal 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
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user