Struct rect stuff
This commit is contained in:
parent
8266d81352
commit
e65f61d113
6
rustbook/rectangles/Cargo.toml
Normal file
6
rustbook/rectangles/Cargo.toml
Normal file
@ -0,0 +1,6 @@
|
||||
[package]
|
||||
name = "rectangles"
|
||||
version = "0.1.0"
|
||||
authors = ["Dan Buch <daniel.buch@gmail.com>"]
|
||||
|
||||
[dependencies]
|
13
rustbook/rectangles/src/main.rs
Normal file
13
rustbook/rectangles/src/main.rs
Normal file
@ -0,0 +1,13 @@
|
||||
fn main() {
|
||||
let width1 = 30;
|
||||
let height1 = 50;
|
||||
|
||||
println!(
|
||||
"The area of the rectangle is {} square pixels.",
|
||||
area(width1, height1)
|
||||
);
|
||||
}
|
||||
|
||||
fn area(width: u32, height: u32) -> u32 {
|
||||
width * height
|
||||
}
|
Loading…
Reference in New Issue
Block a user