Skip to content

Commit

Permalink
Simplify match on nil
Browse files Browse the repository at this point in the history
  • Loading branch information
ahamez committed Oct 16, 2022
1 parent 7eb1b41 commit d85cb8b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/protox/define_encoder.ex
Original file line number Diff line number Diff line change
Expand Up @@ -193,11 +193,11 @@ defmodule Protox.DefineEncoder do
:proto3_optional ->
quote do
case unquote(vars.msg).unquote(child_field.name) do
unquote(var) when not is_nil(unquote(var)) ->
[unquote(vars.acc), unquote(key), unquote(encode_value_ast)]

_ ->
nil ->
[unquote(vars.acc)]

unquote(var) ->
[unquote(vars.acc), unquote(key), unquote(encode_value_ast)]
end
end

Expand Down

0 comments on commit d85cb8b

Please sign in to comment.