View Source Moar.Protocol (Moar v1.62.0)

Protocol-related functions.

Summary

Functions

Returns x or raises if x does not implment protocol.

Returns true if x implements protocol.

Functions

Link to this function

implements!(x, protocol)

View Source
@spec implements!(any(), module()) :: any()

Returns x or raises if x does not implment protocol.

iex> Moar.Protocol.implements!(~D[2000-01-02], String.Chars)
~D[2000-01-02]
Link to this function

implements?(x, protocol)

View Source
@spec implements?(any(), module()) :: boolean()

Returns true if x implements protocol.

iex> Moar.Protocol.implements?(~D[2000-01-02], String.Chars)
true