mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-02-22 06:21:40 +01:00
fn: add UnsafeFromSome to Option API
This commit is contained in:
parent
2ae6b586e3
commit
2499813414
1 changed files with 9 additions and 0 deletions
|
@ -147,3 +147,12 @@ func (o Option[A]) Alt(o2 Option[A]) Option[A] {
|
|||
|
||||
return o2
|
||||
}
|
||||
|
||||
// UnsafeFromSome can be used to extract the internal value. This will panic
|
||||
// if the value is None() though.
|
||||
func (o Option[A]) UnsafeFromSome() A {
|
||||
if o.isSome {
|
||||
return o.some
|
||||
}
|
||||
panic("Option was None()")
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue