summaryrefslogtreecommitdiff
path: root/exercises/06_move_semantics/move_semantics5.rs
diff options
context:
space:
mode:
authormo8it <mo8it@proton.me>2024-04-17 23:34:27 +0200
committermo8it <mo8it@proton.me>2024-04-17 23:34:27 +0200
commit2f810a4da67233716ad93e00afff6e8b260f4807 (patch)
treef5a33357141d25d08b6726910efe33f2338b9cdb /exercises/06_move_semantics/move_semantics5.rs
parentcb9f1ac9ce3c834b0cca964b6809b74508f80b54 (diff)
Clean up and unify exercises
Diffstat (limited to 'exercises/06_move_semantics/move_semantics5.rs')
-rw-r--r--exercises/06_move_semantics/move_semantics5.rs30
1 files changed, 17 insertions, 13 deletions
diff --git a/exercises/06_move_semantics/move_semantics5.rs b/exercises/06_move_semantics/move_semantics5.rs
index c84d2fe..b34560a 100644
--- a/exercises/06_move_semantics/move_semantics5.rs
+++ b/exercises/06_move_semantics/move_semantics5.rs
@@ -1,17 +1,21 @@
-// move_semantics5.rs
-//
-// Make me compile only by reordering the lines in `main()`, but without adding,
+// Make me compile only by reordering the lines in the test, but without adding,
// changing or removing any of them.
-//
-// Execute `rustlings hint move_semantics5` or use the `hint` watch subcommand
-// for a hint.
-#[test]
fn main() {
- let mut x = 100;
- let y = &mut x;
- let z = &mut x;
- *y += 100;
- *z += 1000;
- assert_eq!(x, 1200);
+ // You can optionally experiment here.
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn move_semantics5() {
+ let mut x = 100;
+ let y = &mut x;
+ let z = &mut x;
+ *y += 100;
+ *z += 1000;
+ assert_eq!(x, 1200);
+ }
}