2020-10-26 02:54:32 -04:00
|
|
|
fn array_and_vec() -> ([i32; 4], Vec<i32>) {
|
2024-06-19 19:00:06 -04: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 02:54:32 -04:00
|
|
|
|
|
|
|
(a, v)
|
|
|
|
}
|
|
|
|
|
2024-04-17 16:46:21 -04:00
|
|
|
fn main() {
|
|
|
|
// You can optionally experiment here.
|
|
|
|
}
|
|
|
|
|
2020-10-26 02:54:32 -04:00
|
|
|
#[cfg(test)]
|
|
|
|
mod tests {
|
|
|
|
use super::*;
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_array_and_vec_similarity() {
|
|
|
|
let (a, v) = array_and_vec();
|
2024-06-19 19:00:06 -04:00
|
|
|
assert_eq!(a, *v);
|
2020-10-26 02:54:32 -04:00
|
|
|
}
|
|
|
|
}
|