MCPcopy
hub / github.com/cli/cli / UnwrapOrElse

Method UnwrapOrElse

pkg/option/option.go:91–97  ·  view source on GitHub ↗

UnwrapOrElse returns the underlying value of a [Some] variant, or the result of calling the provided function on a [None] variant.

(f func() T)

Source from the content-addressed store, hash-verified

89// UnwrapOrElse returns the underlying value of a [Some] variant, or the result
90// of calling the provided function on a [None] variant.
91func (o Option[T]) UnwrapOrElse(f func() T) T {
92 if o.present {
93 return o.value
94 }
95
96 return f()
97}
98
99// UnwrapOrZero returns the underlying value of a [Some] variant, or the zero
100// value on a [None] variant.

Callers 3

TestSomeUnwrapOrElseFunction · 0.80
TestNoneUnwrapOrElseFunction · 0.80

Calls

no outgoing calls

Tested by 3

TestSomeUnwrapOrElseFunction · 0.64
TestNoneUnwrapOrElseFunction · 0.64