title: A collection of type `i32` cannot be built from `std::iter::Iterator<Item=_>`
body: <p>Today I try to solve a problem on <a href="https://leetcode.com/problems/day-of-the-year/" rel="nofollow noreferrer">LeetCode</a>. This is my code (<a href="https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=750ec92f41d19231f2fcf1e7ef3c330c" rel="nofollow noreferrer">Playground</a>):</p>
  
  <pre class="lang-rust prettyprint-override"><code>#[test]
  fn basic_test() {
      assert_eq!(day_of_year("2019-01-09".to_string()), 9);
      assert_eq!(day_of_year("2019-02-10".to_string()), 41);
      assert_eq!(day_of_year("2003-03-01".to_string()), 60);
      assert_eq!(day_of_year("2004-03-01".to_string()), 61);
  }
  
  pub fn day_of_year(date: String) -&gt; i32 {
      let vec: Vec&lt;&amp;str&gt; = date.split("-").collect();
      [(vec[0],vec[1],vec[2])].iter().map(|(year,month,day)|
          match month {
              &amp;"01" =&gt; day.parse().unwrap(),
              &amp;"02" =&gt; day.parse().unwrap() + 31,
              _ =&gt; match year.parse().unwrap(){
                  y if y%4==0&amp;&amp;y%100!=0 
                      ||y%400==0&amp;&amp;y%3200!=0 
                      ||y%172800==0=&gt;
                          match month {
                              &amp;"03" =&gt; day.parse().unwrap()+31+29,
                              &amp;"04" =&gt; day.parse().unwrap()+31+29+31,
                              &amp;"05" =&gt; day.parse().unwrap()+31+29+31+30,
                              &amp;"06" =&gt; day.parse().unwrap()+31+29+31+30+31,
                              &amp;"07" =&gt; day.parse().unwrap()+31+29+31+30+31+30,
                              &amp;"08" =&gt; day.parse().unwrap()+31+29+31+30+31+30+31,
                              &amp;"09" =&gt; day.parse().unwrap()+31+29+31+30+31+30+31+31,
                              &amp;"10" =&gt; day.parse().unwrap()+31+29+31+30+31+30+31+31+30,
                              &amp;"11" =&gt; day.parse().unwrap()+31+29+31+30+31+30+31+31+30+31,
                              &amp;"12" =&gt; day.parse().unwrap()+31+29+31+30+31+30+31+31+30+31+30
                          },
                  _ =&gt; match month{
                          &amp;"03" =&gt; day.parse().unwrap()+31+28,
                          &amp;"04" =&gt; day.parse().unwrap()+31+28+31,
                          &amp;"05" =&gt; day.parse().unwrap()+31+28+31+30,
                          &amp;"06" =&gt; day.parse().unwrap()+31+28+31+30+31,
                          &amp;"07" =&gt; day.parse().unwrap()+31+28+31+30+31+30,
                          &amp;"08" =&gt; day.parse().unwrap()+31+28+31+30+31+30+31,
                          &amp;"09" =&gt; day.parse().unwrap()+31+28+31+30+31+30+31+31,
                          &amp;"10" =&gt; day.parse().unwrap()+31+28+31+30+31+30+31+31+30,
                          &amp;"11" =&gt; day.parse().unwrap()+31+28+31+30+31+30+31+31+30+31,
                          &amp;"12" =&gt; day.parse().unwrap()+31+28+31+30+31+30+31+31+30+31+30
                  }
              }
          }
      ).collect()
  }
  </code></pre>
  
  <p>I think the code can self-explain. I'm getting this error message:</p>
  
  <pre class="lang-none prettyprint-override"><code>error[E0277]: a collection of type `i32` cannot be built from an iterator over elements of type `_`
    --&gt; src/lib.rs:45:7
     |
  45 |     ).collect()
     |       ^^^^^^^ a collection of type `i32` cannot be built from `std::iter::Iterator&lt;Item=_&gt;`
     |
     = help: the trait `std::iter::FromIterator&lt;_&gt;` is not implemented for `i32`
  </code></pre>
  
  <p>I tried changing it to <code>collect::&lt;Vec&lt;i32&gt;&gt;[0]</code>. But still getting the compile error. Let me know how can I change the code to make it compile.</p>