Implemented structs
This commit is contained in:
parent
50fc8c6249
commit
e36d9fade3
32 changed files with 267 additions and 63 deletions
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue