MCPcopy Index your code
hub / github.com/cli/cli / UnwrapOr

Method UnwrapOr

pkg/option/option.go:81–87  ·  view source on GitHub ↗

UnwrapOr returns the underlying value of a [Some] variant, or the provided value on a [None] variant.

(value T)

Source from the content-addressed store, hash-verified

79// UnwrapOr returns the underlying value of a [Some] variant, or the provided
80// value on a [None] variant.
81func (o Option[T]) UnwrapOr(value T) T {
82 if o.present {
83 return o.value
84 }
85
86 return value
87}
88
89// UnwrapOrElse returns the underlying value of a [Some] variant, or the result
90// of calling the provided function on a [None] variant.

Callers 4

ExampleOption_UnwrapOrFunction · 0.80
TestSomeUnwrapOrFunction · 0.80
TestNoneUnwrapOrFunction · 0.80

Calls

no outgoing calls

Tested by 3

ExampleOption_UnwrapOrFunction · 0.64
TestSomeUnwrapOrFunction · 0.64
TestNoneUnwrapOrFunction · 0.64