It might help if you think of it more as type-hint. Although it is a pattern match, the syntax here reminds me of other languages (e.g. PHP, Python, or Go) that put data types in the function signatures.
But since it's Elixir, it IS a pattern match, and it is an idiomatic way to communicate the intent of that particular function clause or to set yourself up to define other function clauses. For example, imagine these function clauses defined alongside the example you provided:
def change_user(%LegacyUser{} = legacy_user) do
LegacyUser.changeset(legacy_user, %{})
end
def change_user(arg) do
Logger.error("Unsupported argument given to change_user/1: #{inspect(arg)}")
end
Although functionally, it doesn't matter if you do %User{} = user
or user = %User{}
, it is more idiomatic to use the former.