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