rustlings

solving rustlings ft. dracuxan
git clone [email protected]:dracuxan/rustlings.git
Log | Files | Refs

vecs1.rs (491B)


      1 fn array_and_vec() -> ([i32; 4], Vec<i32>) {
      2     let a = [10, 20, 30, 40]; // Array
      3 
      4     // TODO: Create a vector called `v` which contains the exact same elements as in the array `a`.
      5     // Use the vector macro.
      6     let v = vec![10, 20, 30, 40];
      7 
      8     (a, v)
      9 }
     10 
     11 fn main() {
     12     // You can optionally experiment here.
     13 }
     14 
     15 #[cfg(test)]
     16 mod tests {
     17     use super::*;
     18 
     19     #[test]
     20     fn test_array_and_vec_similarity() {
     21         let (a, v) = array_and_vec();
     22         assert_eq!(a, *v);
     23     }
     24 }