title: Reason of the error expected (), found struct `std::vec::Vec` in Rust?
body: <p>I am new to rust programming. I wanted to implement merge sort with recursion. Here is my code:</p>
  
  <pre class="lang-rust prettyprint-override"><code>fn merge(a: &amp;mut Vec&lt;u32&gt;, b: &amp;mut Vec&lt;u32&gt;) -&gt; Vec&lt;u32&gt; {
      let mut temp: Vec&lt;u32&gt; = Vec::new();
  
      println!("The digit is {}", a[0]);
      while a.len() &gt; 0 &amp;&amp; b.len() &gt; 0 {
          if a[0] &gt; b[0] {
              temp.push(a[0]);
              a.pop();
          } else {
              temp.push(b[0]);
              b.pop();
          }
      }
  
      while a.len() &gt; 0 {
          temp.push(a[0]);
          a.pop();
      }
  
      while b.len() &gt; 0 {
          temp.push(b[0]);
          b.pop();
      }
  
      temp
  }
  
  fn merge_sort(v: &amp;mut Vec&lt;u32&gt;) -&gt; Vec&lt;u32&gt; {
      println!("The divided vector is: {:?}", v);
      let n = v.len();
  
      if n == 1 {
          println!("The divided vector is: {:?}", v.to_vec());
          let t: Vec&lt;u32&gt; = Vec::new();
          t.push(v[0]);
          t
      }
  
      if n == 0 {
          panic!("Alas!! NULL");
      }
  
      merge(
          &amp;mut merge_sort(&amp;mut v[0..n / 2].to_vec()),
          &amp;mut merge_sort(&amp;mut v[n / 2 + 1..n].to_vec()),
      )
      .to_vec()
  }
  
  fn main() {
      let mut v = vec![23, 78, 89, 64, 23, 12, 79, 45, 64];
      println!("The vector is: {:?}", v);
      println!("The length {}", v.len());
  
      let v = merge_sort(&amp;mut v);
  
      println!("The sorted vector is: {:?}", v);
  }
  
  </code></pre>
  
  <p>The problem is, when I am trying to compile it, I am getting the following error:</p>
  
  <pre class="lang-none prettyprint-override"><code>error[E0308]: mismatched types
    --&gt; src/main.rs:36:9
     |
  32 | /     if n == 1 {
  33 | |         println!("The divided vector is: {:?}", v.to_vec());
  34 | |         let t: Vec&lt;u32&gt; = Vec::new();
  35 | |         t.push(v[0]);
  36 | |         t
     | |         ^ expected `()`, found struct `std::vec::Vec`
  37 | |     }
     | |     -- help: consider using a semicolon here
     | |_____|
     |       expected this to be `()`
     |
     = note: expected unit type `()`
                   found struct `std::vec::Vec&lt;u32&gt;`
  </code></pre>
  
  <p>Do you have any idea why am I getting this strange error! It seems, I am missing something.</p>