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
|