Skip to content

Commit 752bc27

Browse files
committed
Auto merge of #179 - briankung:fix_irrefutable_let_pattern_structs1, r=komaeda
Fixes the irrefutable let pattern warning in `structs1.rs` PR #163 accidentally introduced an error using some versions of the Rust compiler where the compiler would (rightly!) complain about an irrefutable let pattern. I have no idea why this did not occur in all versions of the compiler, but here is a way around it.
2 parents b8d59d6 + cc6a141 commit 752bc27

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

exercises/structs/structs1.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ struct ColorClassicStruct {
77

88
struct ColorTupleStruct(/* TODO: Something goes here */);
99

10-
struct ColorUnitStruct;
10+
#[derive(Debug)]
11+
struct UnitStruct;
1112

1213
#[cfg(test)]
1314
mod tests {
@@ -35,12 +36,9 @@ mod tests {
3536
#[test]
3637
fn unit_structs() {
3738
// TODO: Instantiate a unit struct!
38-
// let green =
39+
// let unit_struct =
40+
let message = format!("{:?}s are fun!", unit_struct);
3941

40-
if let ColorUnitStruct = green {
41-
assert!(true);
42-
} else {
43-
assert!(false);
44-
}
42+
assert_eq!(message, "UnitStructs are fun!");
4543
}
4644
}

0 commit comments

Comments
 (0)