-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6e7a55f
commit f34f7ab
Showing
2 changed files
with
35 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
defmodule MishkaInstaller.Installer.Collect do | ||
@moduledoc false | ||
# Based on | ||
# https://elixir-lang.slack.com/archives/C03EPRA3B/p1719319847338759?thread_ts=1719318192.858049&cid=C03EPRA3B | ||
defstruct [:callback, acc: nil] | ||
|
||
defimpl Collectable do | ||
alias MishkaInstaller.Installer.Collect | ||
|
||
def into(%Collect{acc: acc, callback: callback}) do | ||
collector_fun = fn | ||
acc, {:cont, elem} -> callback.(elem, acc) | ||
acc, :done -> acc | ||
_acc, :halt -> :ok | ||
end | ||
|
||
{acc, collector_fun} | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters