aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/internal/cm/result.go
diff options
context:
space:
mode:
authorRandy Reddig <[email protected]>2024-11-04 23:32:17 +0100
committerGitHub <[email protected]>2024-11-04 14:32:17 -0800
commitc02a8141c7974e3e3a3deebd38c9ff64c6511c33 (patch)
tree7012413514e210e7b9ef7bb3c83d28b4b540ab76 /src/internal/cm/result.go
parent5862b481a4e1801cecbc1daa891de2289ac734f7 (diff)
downloadtinygo-c02a8141c7974e3e3a3deebd38c9ff64c6511c33.tar.gz
tinygo-c02a8141c7974e3e3a3deebd38c9ff64c6511c33.zip
internal/wasm-tools, syscall: update to [email protected] (#4577)
* internal/wasm-tools, internal/cm: update wasm-tools-go to v0.3.1 and regenerate bindings * syscall: use new (cm.Result).Result() method instead of OK() and Err()
Diffstat (limited to 'src/internal/cm/result.go')
-rw-r--r--src/internal/cm/result.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/internal/cm/result.go b/src/internal/cm/result.go
index 82200e278..781dccc1a 100644
--- a/src/internal/cm/result.go
+++ b/src/internal/cm/result.go
@@ -71,6 +71,16 @@ func (r *result[Shape, OK, Err]) Err() *Err {
return (*Err)(unsafe.Pointer(&r.data))
}
+// Result returns (OK, zero value of Err, false) if r represents the OK case,
+// or (zero value of OK, Err, true) if r represents the error case.
+// This does not have a pointer receiver, so it can be chained.
+func (r result[Shape, OK, Err]) Result() (ok OK, err Err, isErr bool) {
+ if r.isErr {
+ return ok, *(*Err)(unsafe.Pointer(&r.data)), true
+ }
+ return *(*OK)(unsafe.Pointer(&r.data)), err, false
+}
+
// This function is sized so it can be inlined and optimized away.
func (r *result[Shape, OK, Err]) validate() {
var shape Shape