Skip to content

Commit 6f83f13

Browse files
Update README with tiny corrections
1 parent 815301a commit 6f83f13

File tree

2 files changed

+21
-20
lines changed

2 files changed

+21
-20
lines changed

README.md

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
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
1212
end
1313
```
1414

15-
and run `$ mix deps.get`.
15+
and run `$ mix deps.get`.
1616

1717
## Usage
1818

19-
2019
```elixir
2120
defmodule User do
2221
use QuickStruct, [firstname: String.t, name: String.t]
2322
end
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
2828
iex(3)> User.make("Jon", "Adams")
2929
%User{firstname: "Jon", name: "Adams"}
3030
iex(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
3838
defmodule QuickStructTest.Pair do
3939
use QuickStruct, [:first, :second]
4040
end
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]
4849
defstruct [:firstname, :name]
@@ -62,15 +63,15 @@ def make(fields) do
6263
end
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
6970
require QuickStruct
7071
QuickStruct.define_module(User, [firstname: String.t, name: String.t])
7172
QuickStruct.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
7677
defmodule User do

lib/quick_struct.ex

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ defmodule QuickStruct do
66
You have to "use" this module and give a list of fields or a
77
keyword list with fields and specs to create a struct.
88
9-
As an alternative you can create a module and a struct together,
10-
therefor require QuickStruct and call `define_module/2`.
9+
As an alternative you can create a module and a struct together;
10+
just require QuickStruct and call `define_module/2`.
1111
1212
## Examples
13-
Imagine you define the following structs:
13+
Assume you define the following structs:
1414
1515
```
1616
defmodule QuickStructTest.User do
@@ -28,8 +28,8 @@ defmodule QuickStruct do
2828
QuickStruct.define_module QuickStructTest.User, [firstname: String.t, name: String.t]
2929
QuickStruct.define_module QuickStructTest.Pair, [:first, :second]
3030
```
31-
To create a struct you can either use `make/1` with a keyword-list to specify
32-
the fields or use `make`, where each argument is one field (order matters):
31+
To create a struct you can either use `make/1` with a keyword list to specify
32+
the fields, or use `make`, where each argument is one field (order matters):
3333
3434
iex> alias QuickStructTest.User
3535
iex> User.make("Jon", "Adams")
@@ -99,8 +99,8 @@ defmodule QuickStruct do
9999
types = Keyword.values(fieldspecs)
100100
args = Enum.map(fields, &{&1, [], __MODULE__})
101101
# This does something similar to Macro.generate_arguments/2, but
102-
# with the original fieldnames as arguments (better for generated
103-
# documentation of the function)
102+
# with the original field names as arguments (better for generated
103+
# documentation of the function).
104104

105105
quote do
106106
@type t :: %__MODULE__{unquote_splicing(fieldspecs)}
@@ -142,7 +142,7 @@ defmodule QuickStruct do
142142
end
143143

144144
@doc """
145-
Defines a module and a struct with the given field-list.
145+
Defines a module together with a struct with the given field list.
146146
147147
## Example
148148
@@ -170,7 +170,7 @@ defmodule QuickStruct do
170170
end
171171

172172
@doc """
173-
Generates a function, which will generate a struct with some given default values.
173+
Generates a function which will generate a struct with some given default values.
174174
175175
## Example
176176
```

0 commit comments

Comments
 (0)