11# QuickStruct [ ![ Build Status] ( https://travis-ci.org/active-group/quick-struct.svg?branch=master )] ( https://travis-ci.org/active-group/quick-struct )
22
3- Macro to create datastructures as structs without boilerplate.
3+ Macro to create data structures as structs with less boilerplate.
44
55## Installation
66
@@ -12,37 +12,38 @@ def deps do
1212end
1313```
1414
15- and run ` $ mix deps.get ` .
15+ and run ` $ mix deps.get ` .
1616
1717## Usage
1818
19-
2019``` elixir
2120defmodule User do
2221 use QuickStruct , [firstname: String .t , name: String .t ]
2322end
2423```
2524
26- Now you can use ` User.t ` in ` @type ` and ` @spec ` declarations. To create instances of your datastructure, use one of the following options:
25+ Now you can use ` User.t ` in ` @type ` and ` @spec ` declarations. To create
26+ instances of your data structure, use one of the following options:
2727``` elixir
2828iex (3 )> User .make (" Jon" , " Adams" )
2929%User {firstname: " Jon" , name: " Adams" }
3030iex (4 )> User .make ([name: " Adams" , firstname: " Jon" ])
3131%User {firstname: " Jon" , name: " Adams" }
32- iex (5 )> %User {name: " Adams" , firstname: " Jon" }
32+ iex (5 )> %User {name: " Adams" , firstname: " Jon" }
3333%User {firstname: " Jon" , name: " Adams" }
3434```
3535
36- You can also define a struct without types, e.g. :
36+ You can also define a struct without types, for instance :
3737``` elixir
3838defmodule QuickStructTest .Pair do
3939 use QuickStruct , [:first , :second ]
4040end
4141```
4242
43- ### Resulted code
43+ ### Resulting code
4444
45- So the QuickStrcut macro is a very shorthand possibility to define a struct, a datatype and enforce all fields. The ` User ` -struct is equivalent to:
45+ The QuickStruct macro is a very shorthand option to define a struct, a
46+ data type and enforce all fields. The ` User ` -struct is equivalent to:
4647``` elixir
4748@enforce_keys [:firstname , :name ]
4849defstruct [:firstname , :name ]
@@ -62,15 +63,15 @@ def make(fields) do
6263end
6364```
6465
65- ### Create module and struct
66+ ### Creating modules and structs
6667
67- If you need plenty of different datastructures , you can use
68+ If you need plenty of different data structures , you can use
6869``` elixir
6970require QuickStruct
7071QuickStruct .define_module (User , [firstname: String .t , name: String .t ])
7172QuickStruct .define_module (Pair , [:first , :second ])
7273```
73- to create a module and the struct. So this is shorthand for:
74+ to create a module and the corresponding struct. So this is shorthand for:
7475
7576``` elixir
7677defmodule User do
0 commit comments