Skip to content

Commit

Permalink
core: Loc returns uintptr for addressables
Browse files Browse the repository at this point in the history
  • Loading branch information
ignoramous committed Oct 19, 2024
1 parent f471cfa commit 13f0eae
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions intra/core/closer.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,17 @@ func CloseOp(c io.Closer, op CloserOp) {
}
}

func Loc(x any) uintptr {
v := reflect.ValueOf(x)
k := v.Kind()
switch k {
// [Chan], [Func], [Map], [Pointer], [Slice], [String] or [UnsafePointer]
case reflect.Pointer, reflect.UnsafePointer, reflect.String, reflect.Chan, reflect.Func, reflect.Map, reflect.Slice:
return v.Pointer()
}
return 0
}

// may panic or return false if x is not addressable
func IsNotNil(x any) bool {
return !IsNil(x)
Expand Down

0 comments on commit 13f0eae

Please sign in to comment.