Skip to content

Commit 0a96978

Browse files
yllmisyllmis
authored andcommitted
update
1 parent 1ca2aae commit 0a96978

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ edition = "2021"
1111
[dependencies]
1212
argh = "0.1"
1313
indicatif = "0.16"
14-
console = "0.15"
14+
console = "0.16"
1515
notify = "4.0"
1616
toml = "0.5"
1717
regex = "1.5"

exercises/structs/structs1.rs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@
55
// Execute `rustlings hint structs1` or use the `hint` watch subcommand for a
66
// hint.
77

8-
// I AM NOT DONE
98

109
struct ColorClassicStruct {
1110
// TODO: Something goes here
11+
red: u8,
12+
green: u8,
13+
blue: u8,
1214
}
1315

14-
struct ColorTupleStruct(/* TODO: Something goes here */);
16+
struct ColorTupleStruct(u8, u8, u8);
1517

1618
#[derive(Debug)]
1719
struct UnitLikeStruct;
@@ -23,7 +25,12 @@ mod tests {
2325
#[test]
2426
fn classic_c_structs() {
2527
// TODO: Instantiate a classic c struct!
26-
// let green =
28+
let green = ColorClassicStruct {
29+
red: 0,
30+
green: 255,
31+
blue: 0,
32+
};
33+
2734

2835
assert_eq!(green.red, 0);
2936
assert_eq!(green.green, 255);
@@ -33,7 +40,7 @@ mod tests {
3340
#[test]
3441
fn tuple_structs() {
3542
// TODO: Instantiate a tuple struct!
36-
// let green =
43+
let green = ColorTupleStruct(0, 255, 0);
3744

3845
assert_eq!(green.0, 0);
3946
assert_eq!(green.1, 255);
@@ -43,7 +50,7 @@ mod tests {
4350
#[test]
4451
fn unit_structs() {
4552
// TODO: Instantiate a unit-like struct!
46-
// let unit_like_struct =
53+
let unit_like_struct = UnitLikeStruct;
4754
let message = format!("{:?}s are fun!", unit_like_struct);
4855

4956
assert_eq!(message, "UnitLikeStructs are fun!");

0 commit comments

Comments
 (0)