title: Iterate, filter and map data from one struct to another in Rust
body: <p><strong>Struct</strong></p>
  <pre><code>pub struct UserAccess {
      pub user: String,
      pub dept: String,
      pub hreflink: String,
  }
  
  pub struct RoleMembers {
      pub role: String,
      pub members: Vec&lt;String&gt;,
  }
  
  
  pub struct DepartmentAccess {
      pub department: String,
      pub department_id: String,
      pub role_members: Vec&lt;RoleMembers&gt;,
  }
  </code></pre>
  <p>I am trying to filter data in <em>DepartmentAccess</em> struct based on input ('user' &amp; 'department') from UI and need to map 'user', 'departmentid' and a 'reflink' to another struct (<em>UserAccess</em>) which required for UI. But while building it's throwing error as below. What do I need to do here?</p>
  <p><strong>Code</strong></p>
  <pre><code>  let mut v: Vec&lt;UserAccess&gt; = vec![];
      let access_data = get_access_data();
      let user_data: Vec&lt;UserAccess&gt; = access_data
          .into_iter()
          .filter(|a| a.department == department &amp;&amp; a.role_members.iter().any(|b| b.members.contains(&amp;user)))
          .map(|r| {
              v.push(UserAccess {
                  user: user,
                  dept: r.department_id,
                  hreflink: format!(&quot;department/{}&quot;, r.department_id),
              })
          })
          .collect();
  </code></pre>
  <p><strong>Error</strong></p>
  <pre><code>value of type `Vec&lt;UserAccess&gt;` cannot be built from `std::iter::Iterator&lt;Item=()&gt;`
     |
     = help: the trait `FromIterator&lt;()&gt;` is not implemented for `Vec&lt;UserAccess&gt;`
  </code></pre>