summaryrefslogtreecommitdiff
path: root/rustlings/solutions/05_vecs/vecs1.rs
diff options
context:
space:
mode:
authorHunter Kvalevog <hunter@kvog.sh>2026-09-18 16:34:17 -0500
committerHunter Kvalevog <hunter@kvog.sh>2026-09-18 16:34:17 -0500
commit177787395f4179e8510adfba52e211b151774372 (patch)
tree2c7229af2b1214c649c8d02ee4eb94f7e58f2c12 /rustlings/solutions/05_vecs/vecs1.rs
parent8f0234e3a297d99c958e8b85e131ec9323cd53c7 (diff)
rustlings: complete 05
Diffstat (limited to 'rustlings/solutions/05_vecs/vecs1.rs')
-rw-r--r--rustlings/solutions/05_vecs/vecs1.rs23
1 files changed, 21 insertions, 2 deletions
diff --git a/rustlings/solutions/05_vecs/vecs1.rs b/rustlings/solutions/05_vecs/vecs1.rs
index dcf2377..55b5676 100644
--- a/rustlings/solutions/05_vecs/vecs1.rs
+++ b/rustlings/solutions/05_vecs/vecs1.rs
@@ -1,4 +1,23 @@
+fn array_and_vec() -> ([i32; 4], Vec<i32>) {
+ let a = [10, 20, 30, 40]; // Array
+
+ // Used the `vec!` macro.
+ let v = vec![10, 20, 30, 40];
+
+ (a, v)
+}
+
fn main() {
- // DON'T EDIT THIS SOLUTION FILE!
- // It will be automatically filled after you finish the exercise.
+ // You can optionally experiment here.
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn test_array_and_vec_similarity() {
+ let (a, v) = array_and_vec();
+ assert_eq!(a, *v);
+ }
}