From 1e622a7a597811f7217c0b9a97ffaed71d966a03 Mon Sep 17 00:00:00 2001 From: Alexandre Hamez Date: Fri, 15 Nov 2024 22:10:06 +0100 Subject: [PATCH] refactor: remove custom implementation of Keyword.pop_values/2 It has been present since Elixir 1.10 --- lib/mix/tasks/protox/generate.ex | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/lib/mix/tasks/protox/generate.ex b/lib/mix/tasks/protox/generate.ex index f2bcf039..8855d95a 100644 --- a/lib/mix/tasks/protox/generate.ex +++ b/lib/mix/tasks/protox/generate.ex @@ -33,7 +33,7 @@ defmodule Mix.Tasks.Protox.Generate do def run(args) do with {opts, files, []} <- OptionParser.parse(args, strict: @options), {:ok, output_path} <- Keyword.fetch(opts, :output_path), - {include_paths, opts} = pop_values(opts, :include_path), + {include_paths, opts} = Keyword.pop_values(opts, :include_path), {multiple_files, opts} = Keyword.pop(opts, :multiple_files, false), {:ok, files_content} <- generate(files, output_path, multiple_files, include_paths, opts) do @@ -51,17 +51,6 @@ defmodule Mix.Tasks.Protox.Generate do File.write!(file_name, content) end - # Custom implementation as Keyword.pop_values/2 is only available since Elixir 1.10 - defp pop_values(opts, key) do - {values, new_opts} = - Enum.reduce(opts, {[], []}, fn - {^key, value}, {values, new_opts} -> {[value | values], new_opts} - {key, value}, {values, new_opts} -> {values, [{key, value} | new_opts]} - end) - - {Enum.reverse(values), Enum.reverse(new_opts)} - end - defp generate(files, output_path, multiple_files, include_paths, opts) do Protox.Generate.generate_module_code( files,