Structo (structo v0.1.0)

View Source

JavaScript-style object constructors.

This library allows you to construct maps and structs like this:

~m{a, b}

Instead of:

%{a: a, b: b}

And it works in matches too:

iex> ~m{a, b} = %{a: 1, b: 2}
iex> a
1
iex> b
2

Structs

The library works for structs too. Just use Structo in your module:

defmodule MyStruct do
  use Structo
  defstruct [:a, :b]
end

And then construct your structs like this:

import MyStruct
~MYSTRUCT{a, b}

(Unfortunately, the struct name has to be upcased.)

Summary

Functions

sigil_m(arg, list)

(macro)