mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-01-18 21:35:24 +01:00
fn: breaking - rename ChainOption to FlatMapOption for consistency
This commit is contained in:
parent
5e947046a3
commit
dd7f1569c7
@ -133,11 +133,11 @@ func FlattenOption[A any](oo Option[Option[A]]) Option[A] {
|
||||
return oo.some
|
||||
}
|
||||
|
||||
// ChainOption transforms a function A -> Option[B] into one that accepts an
|
||||
// FlatMapOption transforms a function A -> Option[B] into one that accepts an
|
||||
// Option[A] as an argument.
|
||||
//
|
||||
// ChainOption : (A -> Option[B]) -> Option[A] -> Option[B].
|
||||
func ChainOption[A, B any](f func(A) Option[B]) func(Option[A]) Option[B] {
|
||||
// FlatMapOption : (A -> Option[B]) -> Option[A] -> Option[B].
|
||||
func FlatMapOption[A, B any](f func(A) Option[B]) func(Option[A]) Option[B] {
|
||||
return func(o Option[A]) Option[B] {
|
||||
if o.isSome {
|
||||
return f(o.some)
|
||||
|
@ -383,7 +383,7 @@ func TestPropLastTailIsLast(t *testing.T) {
|
||||
return true
|
||||
}
|
||||
|
||||
return Last(s) == ChainOption(Last[uint8])(Tail(s))
|
||||
return Last(s) == FlatMapOption(Last[uint8])(Tail(s))
|
||||
}
|
||||
|
||||
require.NoError(t, quick.Check(f, nil))
|
||||
@ -396,7 +396,7 @@ func TestPropHeadInitIsHead(t *testing.T) {
|
||||
return true
|
||||
}
|
||||
|
||||
return Head(s) == ChainOption(Head[uint8])(Init(s))
|
||||
return Head(s) == FlatMapOption(Head[uint8])(Init(s))
|
||||
}
|
||||
|
||||
require.NoError(t, quick.Check(f, nil))
|
||||
|
Loading…
Reference in New Issue
Block a user