1
0
mirror of https://github.com/rust-lang/rustlings.git synced 2025-02-11 13:39:00 +02:00

25 lines
477 B
Rust
Raw Normal View History

2020-10-26 12:54:32 +06:00
fn array_and_vec() -> ([i32; 4], Vec<i32>) {
2024-06-20 01:00:06 +02:00
let a = [10, 20, 30, 40]; // Array
// TODO: Create a vector called `v` which contains the exact same elements as in the array `a`.
// Use the vector macro.
// let v = ???;
2020-10-26 12:54:32 +06:00
(a, v)
}
fn main() {
// You can optionally experiment here.
}
2020-10-26 12:54:32 +06:00
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_array_and_vec_similarity() {
let (a, v) = array_and_vec();
2024-06-20 01:00:06 +02:00
assert_eq!(a, *v);
2020-10-26 12:54:32 +06:00
}
}