From c274db25c4fe0967bdecdec834ba47bf083e43df Mon Sep 17 00:00:00 2001 From: "Carol (Nichols || Goulding)" Date: Fri, 23 Sep 2016 15:34:00 -0400 Subject: [PATCH] Add some notes to Liz --- src/ch05-00-structs.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/ch05-00-structs.md b/src/ch05-00-structs.md index c235fc3e9..a9af7ff00 100644 --- a/src/ch05-00-structs.md +++ b/src/ch05-00-structs.md @@ -134,11 +134,16 @@ fn area(dimensions: (u32, u32)) -> u32 { } ``` + + In one way, this is a little better. Tuples let us add a bit of structure, and we’re now passing just one argument. But in another way this method less clear: tuples don’t give names to their elements, so our calculation has gotten more confusing because we have to index into the parts of the tuple: + + ```rust,ignore dimensions.0 * dimensions.1 ``` @@ -178,6 +183,8 @@ fn area(rectangle: &Rectangle) -> u32 { } ``` + + Here we've defined a `struct` and given it the name `Rectangle`. Inside the `{}` we defined the fields to be `length` and `width`, both of which have type `u32`. Then in `main`, we create a particular instance of a `Rectangle` that