diff options
| author | anand <anand.panchdhari@gmail.com> | 2026-04-05 17:53:10 +0530 |
|---|---|---|
| committer | anand <anand.panchdhari@gmail.com> | 2026-04-05 17:53:10 +0530 |
| commit | e02ea7acdee0ae93a4a6e8426fdd83334a61ac11 (patch) | |
| tree | d21a58a73f6d892929892d5828e614e3aed09319 /exercises/07_structs/structs1.rs | |
| parent | f8d94cce2a21067d666f65d23d591f0f40cf6c36 (diff) | |
I dont know why this is not pushedmain
Diffstat (limited to 'exercises/07_structs/structs1.rs')
| -rwxr-xr-x[-rw-r--r--] | exercises/07_structs/structs1.rs | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/exercises/07_structs/structs1.rs b/exercises/07_structs/structs1.rs index 959c4c6..3da1ce0 100644..100755 --- 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!"); } |
