Add readme instructions
This commit is contained in:
parent
ec45c02f72
commit
09c635039d
1 changed files with 33 additions and 1 deletions
34
README.md
34
README.md
|
|
@ -1,2 +1,34 @@
|
||||||
# subfield
|
# subfield
|
||||||
A sub-field accessor macro for the Nim programming language.
|
A sub-field accessor macro for the Nim programming language. This lets you access nested fields within a Nim object or ref object.
|
||||||
|
|
||||||
|
# Installation
|
||||||
|
|
||||||
|
```bash
|
||||||
|
nimble install subfield
|
||||||
|
```
|
||||||
|
|
||||||
|
#Usage
|
||||||
|
|
||||||
|
```nim
|
||||||
|
import subfield
|
||||||
|
|
||||||
|
type
|
||||||
|
C = object
|
||||||
|
y: int
|
||||||
|
B = object
|
||||||
|
x: int
|
||||||
|
c: C
|
||||||
|
A = ref object
|
||||||
|
b: B
|
||||||
|
|
||||||
|
var c = C(y: 0)
|
||||||
|
var b = B(x: 5, c: c)
|
||||||
|
var a = A(b: b)
|
||||||
|
|
||||||
|
echo a.x
|
||||||
|
echo a.y
|
||||||
|
|
||||||
|
# Prints:
|
||||||
|
# 5
|
||||||
|
# 0
|
||||||
|
```
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue