File: behaviour.ex

package info (click to toggle)
elixir-ex-doc 0.35.1%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,784 kB
  • sloc: javascript: 2,848; makefile: 15; xml: 12; sh: 5
file content (29 lines) | stat: -rw-r--r-- 646 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
defmodule CustomBehaviourOne do
  # Even if we define a struct, this module should still be listed as a behaviour.
  defstruct [:a, :b]

  @doc """
  This is a sample callback.
  """
  @callback hello(%URI{}) :: integer
  @callback greet(integer | String.t()) :: integer
end

defmodule CustomBehaviourTwo do
  @doc """
  This is a different sample callback.
  """
  @macrocallback bye(integer) :: integer
end

defmodule CustomBehaviourImpl do
  @behaviour CustomBehaviourOne
  @behaviour CustomBehaviourTwo

  def hello(i), do: i

  @doc "A doc so it doesn't use 'Callback implementation for'"
  def greet(i), do: i

  defmacro bye(i), do: i
end