luastruct

Type safe data structures in pure lua

$ luarocks install luastruct

I love lua, but i sometimes want to model my ideas in go-style structs,
so i wrote this. here is an example, more are in the readme :)

local struct = require "struct"
local person = struct {
name = "default name",
age = 0
}

local default = person {
age = 10
}

print(default.name) --> "default name"

local bob = person {
name = "bob",
age = 20
}

print(default.name) --> "bob"

-- causes an error because the types do not match.
local invalid = person {
name = 10,
age = "invalid age"
}

Versions

1.1-181 days ago21 downloads
1.0-183 days ago7 downloads
dev-1dev84 days ago1 download

Labels

Manifests