summaryrefslogtreecommitdiff
path: root/rustlings/exercises/07_structs/structs1.rs
diff options
context:
space:
mode:
Diffstat (limited to 'rustlings/exercises/07_structs/structs1.rs')
-rw-r--r--rustlings/exercises/07_structs/structs1.rs47
1 files changed, 47 insertions, 0 deletions
diff --git a/rustlings/exercises/07_structs/structs1.rs b/rustlings/exercises/07_structs/structs1.rs
new file mode 100644
index 0000000..959c4c6
--- /dev/null
+++ b/rustlings/exercises/07_structs/structs1.rs
@@ -0,0 +1,47 @@
+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: Add the fields that the test `tuple_structs` expects */);
+
+#[derive(Debug)]
+struct UnitStruct;
+
+fn main() {
+ // You can optionally experiment here.
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn regular_structs() {
+ // TODO: Instantiate a regular struct.
+ // let green =
+
+ assert_eq!(green.red, 0);
+ assert_eq!(green.green, 255);
+ assert_eq!(green.blue, 0);
+ }
+
+ #[test]
+ fn tuple_structs() {
+ // TODO: Instantiate a tuple struct.
+ // let green =
+
+ assert_eq!(green.0, 0);
+ assert_eq!(green.1, 255);
+ assert_eq!(green.2, 0);
+ }
+
+ #[test]
+ fn unit_structs() {
+ // TODO: Instantiate a unit struct.
+ // let unit_struct =
+ let message = format!("{unit_struct:?}s are fun!");
+
+ assert_eq!(message, "UnitStructs are fun!");
+ }
+}