From e02ea7acdee0ae93a4a6e8426fdd83334a61ac11 Mon Sep 17 00:00:00 2001 From: anand Date: Sun, 5 Apr 2026 17:53:10 +0530 Subject: I dont know why this is not pushed --- exercises/07_structs/structs1.rs | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) mode change 100644 => 100755 exercises/07_structs/structs1.rs (limited to 'exercises/07_structs/structs1.rs') diff --git a/exercises/07_structs/structs1.rs b/exercises/07_structs/structs1.rs old mode 100644 new mode 100755 index 959c4c6..3da1ce0 --- a/exercises/07_structs/structs1.rs +++ b/exercises/07_structs/structs1.rs @@ -1,9 +1,17 @@ struct ColorRegularStruct { // TODO: Add the fields that the test `regular_structs` expects. // What types should the fields have? What are the minimum and maximum values for RGB colors? + red: i32, + green: i32, + blue: i32, } -struct ColorTupleStruct(/* TODO: Add the fields that the test `tuple_structs` expects */); +struct ColorTupleStruct( + /* TODO: Add the fields that the test `tuple_structs` expects */ + i32, + i32, + i32, +); #[derive(Debug)] struct UnitStruct; @@ -19,7 +27,11 @@ mod tests { #[test] fn regular_structs() { // TODO: Instantiate a regular struct. - // let green = + let green = ColorRegularStruct { + red: 0, + green: 255, + blue: 0, + }; assert_eq!(green.red, 0); assert_eq!(green.green, 255); @@ -29,7 +41,7 @@ mod tests { #[test] fn tuple_structs() { // TODO: Instantiate a tuple struct. - // let green = + let green = (0, 255, 0); assert_eq!(green.0, 0); assert_eq!(green.1, 255); @@ -39,8 +51,9 @@ mod tests { #[test] fn unit_structs() { // TODO: Instantiate a unit struct. - // let unit_struct = - let message = format!("{unit_struct:?}s are fun!"); + #[derive(Debug)] + struct UnitStruct; + let message = format!("{UnitStruct:?}s are fun!"); assert_eq!(message, "UnitStructs are fun!"); } -- cgit v1.2.3