defimpl Enumerable, for: BitString do
def count(str), do: {:ok, String.length(str)}
def member?(str, char), do: {:ok, String.contains?(str, char)}
def reduce(_, {:halt, acc}, _fun), do: {:halted, acc}
def reduce(str, {:suspend, acc}, fun) do
{:suspended, acc, &reduce(str, &1, fun)}
end
def reduce("", {:cont, acc}, _fun), do: {:done, acc}
def reduce(str, {:cont, acc}, fun) do
{next, rest} = String.next_grapheme(str)
reduce(rest, fun.(next, acc), fun)
end
def slice(str), do: {:error, __MODULE__}
end