summaryrefslogtreecommitdiff
path: root/exercises/07_structs/structs1.rs
diff options
context:
space:
mode:
authormo8it <mo8it@proton.me>2024-07-03 15:26:35 +0200
committermo8it <mo8it@proton.me>2024-07-03 15:26:35 +0200
commitf5ce4cf0a50e88e0e70d90e139a6e981791c9af0 (patch)
treeb908688a611c6e64ff1bb7a6a94e9547b7b575de /exercises/07_structs/structs1.rs
parent888ad35d10e8bc6832c11fd8268697311497c1c9 (diff)
parentff3e6c05a52aa0c7e558d86404cfe8495a4412fd (diff)
Merge branch 'v6'
Diffstat (limited to 'exercises/07_structs/structs1.rs')
-rw-r--r--exercises/07_structs/structs1.rs36
1 files changed, 16 insertions, 20 deletions
diff --git a/exercises/07_structs/structs1.rs b/exercises/07_structs/structs1.rs
index 5fa5821..959c4c6 100644
--- a/exercises/07_structs/structs1.rs
+++ b/exercises/07_structs/structs1.rs
@@ -1,28 +1,24 @@
-// structs1.rs
-//
-// Address all the TODOs to make the tests pass!
-//
-// Execute `rustlings hint structs1` or use the `hint` watch subcommand for a
-// hint.
-
-// I AM NOT DONE
-
-struct ColorClassicStruct {
- // TODO: Something goes here
+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?
}
-struct ColorTupleStruct(/* TODO: Something goes here */);
+struct ColorTupleStruct(/* TODO: Add the fields that the test `tuple_structs` expects */);
#[derive(Debug)]
-struct UnitLikeStruct;
+struct UnitStruct;
+
+fn main() {
+ // You can optionally experiment here.
+}
#[cfg(test)]
mod tests {
use super::*;
#[test]
- fn classic_c_structs() {
- // TODO: Instantiate a classic c struct!
+ fn regular_structs() {
+ // TODO: Instantiate a regular struct.
// let green =
assert_eq!(green.red, 0);
@@ -32,7 +28,7 @@ mod tests {
#[test]
fn tuple_structs() {
- // TODO: Instantiate a tuple struct!
+ // TODO: Instantiate a tuple struct.
// let green =
assert_eq!(green.0, 0);
@@ -42,10 +38,10 @@ mod tests {
#[test]
fn unit_structs() {
- // TODO: Instantiate a unit-like struct!
- // let unit_like_struct =
- let message = format!("{:?}s are fun!", unit_like_struct);
+ // TODO: Instantiate a unit struct.
+ // let unit_struct =
+ let message = format!("{unit_struct:?}s are fun!");
- assert_eq!(message, "UnitLikeStructs are fun!");
+ assert_eq!(message, "UnitStructs are fun!");
}
}