Skip to content

Commit

Permalink
Exercise 31
Browse files Browse the repository at this point in the history
  • Loading branch information
akshitgautam42 committed Nov 13, 2023
1 parent f6d2d7e commit d726f2a
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions exercises/07_structs/structs1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
// Execute `rustlings hint structs1` or use the `hint` watch subcommand for a
// hint.

// I AM NOT DONE


struct ColorClassicStruct {
// TODO: Something goes here
red :u8,
green:u8,
blue:u8
}

struct ColorTupleStruct(/* TODO: Something goes here */);
struct ColorTupleStruct(u8, u8, u8);

#[derive(Debug)]
struct UnitLikeStruct;
Expand All @@ -23,7 +25,11 @@ mod tests {
#[test]
fn classic_c_structs() {
// TODO: Instantiate a classic c struct!
// let green =
let green = ColorClassicStruct{
red: 0,
green: 255,
blue: 0
};

assert_eq!(green.red, 0);
assert_eq!(green.green, 255);
Expand All @@ -33,7 +39,7 @@ mod tests {
#[test]
fn tuple_structs() {
// TODO: Instantiate a tuple struct!
// let green =
let green = ColorTupleStruct(0,255,0);

assert_eq!(green.0, 0);
assert_eq!(green.1, 255);
Expand All @@ -43,7 +49,7 @@ mod tests {
#[test]
fn unit_structs() {
// TODO: Instantiate a unit-like struct!
// let unit_like_struct =
let unit_like_struct = UnitLikeStruct;
let message = format!("{:?}s are fun!", unit_like_struct);

assert_eq!(message, "UnitLikeStructs are fun!");
Expand Down

0 comments on commit d726f2a

Please sign in to comment.