Implemented structs

This commit is contained in:
Eduard Urbach 2025-02-04 18:16:31 +01:00
parent 50fc8c6249
commit e36d9fade3
Signed by: eduard
GPG key ID: 49226B848C78F6C8
32 changed files with 267 additions and 63 deletions

View file

@ -1,6 +1,21 @@
package types
// Check returns true if the first type can be converted into the second type.
func Check(a *Type, b *Type) bool {
return a == nil || a == b
// Check returns true if the encountered type `a` can be converted into the expected type `b`.
func Check(a Type, b Type) bool {
if a == nil {
return true
}
if a == b {
return true
}
aPointer, aIsPointer := a.(*Pointer)
bPointer, bIsPointer := b.(*Pointer)
if aIsPointer && bIsPointer && (bPointer.To == nil || aPointer.To == bPointer.To) {
return true
}
return false
}