Update Examples

Glen Whitney 2024-08-24 04:23:23 +00:00
parent 7036a8291e
commit 19b452f584

@ -281,6 +281,9 @@ struct Rectangle
top_left: Point top_left: Point
bottom_right: Point bottom_right: Point
fn main() fn main()
// Create struct with field init shorthand // Create struct with field init shorthand
let name = s"Peter" // note s-string let name = s"Peter" // note s-string
@ -299,7 +302,7 @@ fn main()
println! "second point: ({}, {})", bottom_right.x, bottom_right.y println! "second point: ({}, {})", bottom_right.x, bottom_right.y
// Destructure the point using a `let` binding // Destructure the point using a `let` binding
let Point x: left_edge, y: top_edge = point; let Point x: left_edge, y: top_edge = point
let _rectangle = Rectangle let _rectangle = Rectangle
top_left: Point top_left: Point
@ -313,7 +316,7 @@ fn main()
println! "pair contains {:?} and {:?}", pair.0, pair.1 println! "pair contains {:?} and {:?}", pair.0, pair.1
// Destructure a tuple struct // Destructure a tuple struct
let Pair integer, decimal = pair; let Pair integer, decimal = pair
println! "pair contains {:?} and {:?}", integer, decimal println! "pair contains {:?} and {:?}", integer, decimal