File: empty.ex

package info (click to toggle)
erlang-hex 2.0.6-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,204 kB
  • sloc: erlang: 2,950; sh: 203; makefile: 10
file content (52 lines) | stat: -rw-r--r-- 1,107 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# Vendored from hex_solver v0.2.2 (2634e31), do not edit manually

defmodule Hex.Solver.Constraints.Empty do
  @moduledoc false

  use Hex.Solver.Constraints.Impl

  alias Hex.Solver.Constraint
  alias Hex.Solver.Constraints.Empty

  defstruct []

  def any?(%Empty{}), do: false

  def empty?(%Empty{}), do: true

  def allows?(%Empty{}, %Version{}), do: false

  def allows_any?(%Empty{}, constraint), do: Constraint.empty?(constraint)

  def allows_all?(%Empty{}, constraint), do: Constraint.empty?(constraint)

  def difference(%Empty{}, _constraint), do: %Empty{}

  def intersect(%Empty{}, _constraint), do: %Empty{}

  def union(%Empty{}, constraint), do: constraint

  def compare(left, right) do
    raise FunctionClauseError,
      module: __MODULE__,
      function: :compare,
      arity: 2,
      kind: :def,
      args: [left, right],
      clauses: []
  end

  def to_string(%Empty{}) do
    "empty"
  end

  defimpl String.Chars do
    defdelegate to_string(empty), to: Hex.Solver.Constraints.Empty
  end

  defimpl Inspect do
    def inspect(_, _opts) do
      "#Empty<>"
    end
  end
end