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-15 years ago254 downloads
1.0-15 years ago1,834 downloads
dev-1dev5 years ago1 download

Labels

Manifests