1
0
mirror of https://github.com/IBM/fp-go.git synced 2025-06-23 00:27:49 +02:00
Files
fp-go/option/type.go
Dr. Carsten Leue b25de3c7c3 doc: fix case
Signed-off-by: Dr. Carsten Leue <carsten.leue@de.ibm.com>
2023-07-18 15:57:54 +02:00

22 lines
291 B
Go

package option
import (
F "github.com/IBM/fp-go/function"
)
func toType[T any](a any) (T, bool) {
b, ok := a.(T)
return b, ok
}
func ToType[T any](src any) Option[T] {
return F.Pipe1(
src,
Optionize1(toType[T]),
)
}
func ToAny[T any](src T) Option[any] {
return Of(any(src))
}