mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-06-15 19:31:35 +02:00
fn: breaking - remove deprecated Result functions
This commit is contained in:
parent
1805fd6f19
commit
be50dd9acb
23
fn/result.go
23
fn/result.go
@ -64,15 +64,6 @@ func (r Result[T]) IsErr() bool {
|
|||||||
return r.IsRight()
|
return r.IsRight()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Map applies an endomorphic function to the success value if it exists.
|
|
||||||
//
|
|
||||||
// Deprecated: Use MapOk instead.
|
|
||||||
func (r Result[T]) Map(f func(T) T) Result[T] {
|
|
||||||
return Result[T]{
|
|
||||||
MapLeft[T, error](f)(r.Either),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// MapOk applies an endomorphic function to the success value if it exists.
|
// MapOk applies an endomorphic function to the success value if it exists.
|
||||||
func (r Result[T]) MapOk(f func(T) T) Result[T] {
|
func (r Result[T]) MapOk(f func(T) T) Result[T] {
|
||||||
return Result[T]{
|
return Result[T]{
|
||||||
@ -95,25 +86,11 @@ func MapOk[A, B any](f func(A) B) func(Result[A]) Result[B] {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Option returns the success value as an Option.
|
|
||||||
//
|
|
||||||
// Deprecated: Use OkToSome instead.
|
|
||||||
func (r Result[T]) Option() Option[T] {
|
|
||||||
return r.Either.LeftToSome()
|
|
||||||
}
|
|
||||||
|
|
||||||
// OkToSome mutes the error value of the result.
|
// OkToSome mutes the error value of the result.
|
||||||
func (r Result[T]) OkToSome() Option[T] {
|
func (r Result[T]) OkToSome() Option[T] {
|
||||||
return r.Either.LeftToSome()
|
return r.Either.LeftToSome()
|
||||||
}
|
}
|
||||||
|
|
||||||
// WhenResult executes the given function if the Result is a success.
|
|
||||||
//
|
|
||||||
// Deprecated: Use WhenOk instead.
|
|
||||||
func (r Result[T]) WhenResult(f func(T)) {
|
|
||||||
r.WhenLeft(f)
|
|
||||||
}
|
|
||||||
|
|
||||||
// WhenOk executes the given function if the Result is a success.
|
// WhenOk executes the given function if the Result is a success.
|
||||||
func (r Result[T]) WhenOk(f func(T)) {
|
func (r Result[T]) WhenOk(f func(T)) {
|
||||||
r.WhenLeft(f)
|
r.WhenLeft(f)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user