тип
Объявление type внутри lib объявляет вид типа C typedef, но с более строгими правилами:
lib X
type MyInt = Int32
end
В отличие от C, Int32 и MyInt не взаимозаменяемы:
lib X
type MyInt = Int32
fun some_fun(value : MyInt)
end
X.some_fun 1 # Error: argument 'value' of 'X#some_fun' must be X::MyInt, not Int32
Таким образом, объявление type полезно для непрозрачных типов, создаваемых библиотекой C, для которой вы создаёте обёртку. Примером служит тип C FILE, который можно получить с помощью fopen.
Обозначения, используемые в типах typedef, описаны в грамматике типов.
To the extent possible under law, the persons who contributed to this workhave waived
all copyright and related or neighboring rights to this workby associating CC0 with it.
https://crystal-lang.org/reference/1.2/syntax_and_semantics/c_bindings/type.html