title: What's a good solution to drop nil value in a struct for Elixir?
body: <p>For example, I have a struct</p>
  
  <pre><code>post = %Post{title: "Title", desc: nil}
  </code></pre>
  
  <p>And I want to get</p>
  
  <pre><code>%{title: "Title"}
  </code></pre>
  
  <p>My solution is like</p>
  
  <pre><code>post
    |&gt; Map.delete(:__struct__) # change the struct to a Map
    |&gt; Enum.filter(fn {_, v} -&gt; v end)
    |&gt; Enum.into(%{})
  </code></pre>
  
  <p>It works, but is there a better one?</p>
  
  <p><em>Update</em>:</p>
  
  <p>I feel it annoying transforming from Struct to Map, then Enum, then Map again. Is there a concise way?</p>