title: Elixir How to convert a Map struct to a Record struct
body: <p>I have a Record struct and a Map struct like:</p>
  
  <pre><code>defmodule Foo.Bar do
    defstruct boo: nil, baz: nil
  end
  
  defmodule Foo do
    require Record
    Record.defrecord :bar, Foo.Bar, [boo: nil, baz: nil]
  end
  </code></pre>
  
  <p>I can convert the Record to Map like this: </p>
  
  <pre><code>defp update_map({k, v}, map), do: Map.update!(map, k, fn(_) -&gt; v end)
  defp rd2map(rd) do
    Foo.bar(rd) |&gt; Enum.reduce(%Foo.Bar{}, &amp;update_map/2)
  end
  </code></pre>
  
  <p>But how can I convert the Map to a Record?</p>