Documentation ¶
Index ¶
- func Unzip10[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10 any](o Optional[tuple.Tuple10[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]]) (Optional[T1], Optional[T2], Optional[T3], Optional[T4], Optional[T5], ...)
- func Unzip11[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11 any](o Optional[tuple.Tuple11[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11]]) (Optional[T1], Optional[T2], Optional[T3], Optional[T4], Optional[T5], ...)
- func Unzip12[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12 any](o Optional[tuple.Tuple12[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12]]) (Optional[T1], Optional[T2], Optional[T3], Optional[T4], Optional[T5], ...)
- func Unzip13[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13 any](...) (Optional[T1], Optional[T2], Optional[T3], Optional[T4], Optional[T5], ...)
- func Unzip14[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14 any](...) (Optional[T1], Optional[T2], Optional[T3], Optional[T4], Optional[T5], ...)
- func Unzip15[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15 any](...) (Optional[T1], Optional[T2], Optional[T3], Optional[T4], Optional[T5], ...)
- func Unzip16[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16 any](...) (Optional[T1], Optional[T2], Optional[T3], Optional[T4], Optional[T5], ...)
- func Unzip2[T1, T2 any](o Optional[tuple.Tuple2[T1, T2]]) (Optional[T1], Optional[T2])
- func Unzip3[T1, T2, T3 any](o Optional[tuple.Tuple3[T1, T2, T3]]) (Optional[T1], Optional[T2], Optional[T3])
- func Unzip4[T1, T2, T3, T4 any](o Optional[tuple.Tuple4[T1, T2, T3, T4]]) (Optional[T1], Optional[T2], Optional[T3], Optional[T4])
- func Unzip5[T1, T2, T3, T4, T5 any](o Optional[tuple.Tuple5[T1, T2, T3, T4, T5]]) (Optional[T1], Optional[T2], Optional[T3], Optional[T4], Optional[T5])
- func Unzip6[T1, T2, T3, T4, T5, T6 any](o Optional[tuple.Tuple6[T1, T2, T3, T4, T5, T6]]) (Optional[T1], Optional[T2], Optional[T3], Optional[T4], Optional[T5], ...)
- func Unzip7[T1, T2, T3, T4, T5, T6, T7 any](o Optional[tuple.Tuple7[T1, T2, T3, T4, T5, T6, T7]]) (Optional[T1], Optional[T2], Optional[T3], Optional[T4], Optional[T5], ...)
- func Unzip8[T1, T2, T3, T4, T5, T6, T7, T8 any](o Optional[tuple.Tuple8[T1, T2, T3, T4, T5, T6, T7, T8]]) (Optional[T1], Optional[T2], Optional[T3], Optional[T4], Optional[T5], ...)
- func Unzip9[T1, T2, T3, T4, T5, T6, T7, T8, T9 any](o Optional[tuple.Tuple9[T1, T2, T3, T4, T5, T6, T7, T8, T9]]) (Optional[T1], Optional[T2], Optional[T3], Optional[T4], Optional[T5], ...)
- type Optional
- func Map[T, U any](v Optional[T], f func(T) U) Optional[U]
- func New[T any](v T) Optional[T]
- func None[T any]() Optional[T]
- func Zip10[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10 any](o1 Optional[T1], o2 Optional[T2], o3 Optional[T3], o4 Optional[T4], ...) Optional[tuple.Tuple10[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]]
- func Zip11[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11 any](o1 Optional[T1], o2 Optional[T2], o3 Optional[T3], o4 Optional[T4], ...) Optional[tuple.Tuple11[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11]]
- func Zip12[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12 any](o1 Optional[T1], o2 Optional[T2], o3 Optional[T3], o4 Optional[T4], ...) Optional[tuple.Tuple12[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12]]
- func Zip13[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13 any](o1 Optional[T1], o2 Optional[T2], o3 Optional[T3], o4 Optional[T4], ...) ...
- func Zip14[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14 any](o1 Optional[T1], o2 Optional[T2], o3 Optional[T3], o4 Optional[T4], ...) ...
- func Zip15[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15 any](o1 Optional[T1], o2 Optional[T2], o3 Optional[T3], o4 Optional[T4], ...) ...
- func Zip16[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16 any](o1 Optional[T1], o2 Optional[T2], o3 Optional[T3], o4 Optional[T4], ...) ...
- func Zip2[T1, T2 any](o1 Optional[T1], o2 Optional[T2]) Optional[tuple.Tuple2[T1, T2]]
- func Zip3[T1, T2, T3 any](o1 Optional[T1], o2 Optional[T2], o3 Optional[T3]) Optional[tuple.Tuple3[T1, T2, T3]]
- func Zip4[T1, T2, T3, T4 any](o1 Optional[T1], o2 Optional[T2], o3 Optional[T3], o4 Optional[T4]) Optional[tuple.Tuple4[T1, T2, T3, T4]]
- func Zip5[T1, T2, T3, T4, T5 any](o1 Optional[T1], o2 Optional[T2], o3 Optional[T3], o4 Optional[T4], ...) Optional[tuple.Tuple5[T1, T2, T3, T4, T5]]
- func Zip6[T1, T2, T3, T4, T5, T6 any](o1 Optional[T1], o2 Optional[T2], o3 Optional[T3], o4 Optional[T4], ...) Optional[tuple.Tuple6[T1, T2, T3, T4, T5, T6]]
- func Zip7[T1, T2, T3, T4, T5, T6, T7 any](o1 Optional[T1], o2 Optional[T2], o3 Optional[T3], o4 Optional[T4], ...) Optional[tuple.Tuple7[T1, T2, T3, T4, T5, T6, T7]]
- func Zip8[T1, T2, T3, T4, T5, T6, T7, T8 any](o1 Optional[T1], o2 Optional[T2], o3 Optional[T3], o4 Optional[T4], ...) Optional[tuple.Tuple8[T1, T2, T3, T4, T5, T6, T7, T8]]
- func Zip9[T1, T2, T3, T4, T5, T6, T7, T8, T9 any](o1 Optional[T1], o2 Optional[T2], o3 Optional[T3], o4 Optional[T4], ...) Optional[tuple.Tuple9[T1, T2, T3, T4, T5, T6, T7, T8, T9]]
- func (v Optional[T]) Filter(f func(T) bool) Optional[T]
- func (v Optional[T]) FilterFalse(f func(T) bool) Optional[T]
- func (v Optional[T]) Get() T
- func (v Optional[T]) GetOr(defaults T) T
- func (v Optional[T]) GetOrFunc(f func() T) T
- func (v Optional[T]) GetOrZero() T
- func (v Optional[T]) Valid() bool
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Unzip10 ¶
func Unzip10[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10 any](o Optional[tuple.Tuple10[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]]) (Optional[T1], Optional[T2], Optional[T3], Optional[T4], Optional[T5], Optional[T6], Optional[T7], Optional[T8], Optional[T9], Optional[T10])
Unzip10 converts an optional of 10-tuple to optionals of each elements.
func Unzip11 ¶
func Unzip11[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11 any](o Optional[tuple.Tuple11[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11]]) (Optional[T1], Optional[T2], Optional[T3], Optional[T4], Optional[T5], Optional[T6], Optional[T7], Optional[T8], Optional[T9], Optional[T10], Optional[T11])
Unzip11 converts an optional of 11-tuple to optionals of each elements.
func Unzip12 ¶
func Unzip12[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12 any](o Optional[tuple.Tuple12[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12]]) (Optional[T1], Optional[T2], Optional[T3], Optional[T4], Optional[T5], Optional[T6], Optional[T7], Optional[T8], Optional[T9], Optional[T10], Optional[T11], Optional[T12])
Unzip12 converts an optional of 12-tuple to optionals of each elements.
func Unzip13 ¶
func Unzip13[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13 any](o Optional[tuple.Tuple13[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13]]) (Optional[T1], Optional[T2], Optional[T3], Optional[T4], Optional[T5], Optional[T6], Optional[T7], Optional[T8], Optional[T9], Optional[T10], Optional[T11], Optional[T12], Optional[T13])
Unzip13 converts an optional of 13-tuple to optionals of each elements.
func Unzip14 ¶
func Unzip14[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14 any](o Optional[tuple.Tuple14[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14]]) (Optional[T1], Optional[T2], Optional[T3], Optional[T4], Optional[T5], Optional[T6], Optional[T7], Optional[T8], Optional[T9], Optional[T10], Optional[T11], Optional[T12], Optional[T13], Optional[T14])
Unzip14 converts an optional of 14-tuple to optionals of each elements.
func Unzip15 ¶
func Unzip15[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15 any](o Optional[tuple.Tuple15[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15]]) (Optional[T1], Optional[T2], Optional[T3], Optional[T4], Optional[T5], Optional[T6], Optional[T7], Optional[T8], Optional[T9], Optional[T10], Optional[T11], Optional[T12], Optional[T13], Optional[T14], Optional[T15])
Unzip15 converts an optional of 15-tuple to optionals of each elements.
func Unzip16 ¶
func Unzip16[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16 any](o Optional[tuple.Tuple16[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16]]) (Optional[T1], Optional[T2], Optional[T3], Optional[T4], Optional[T5], Optional[T6], Optional[T7], Optional[T8], Optional[T9], Optional[T10], Optional[T11], Optional[T12], Optional[T13], Optional[T14], Optional[T15], Optional[T16])
Unzip16 converts an optional of 16-tuple to optionals of each elements.
func Unzip2 ¶
Unzip2 converts an optional of 2-tuple to optionals of each elements.
Example ¶
package main import ( "fmt" "github.com/shogo82148/hi/optional" "github.com/shogo82148/hi/tuple" ) func main() { o1, o2 := optional.Unzip2(optional.New(tuple.New2(1, "one"))) fmt.Println(o1.GetOrZero()) fmt.Println(o2.GetOrZero()) }
Output: 1 one
func Unzip3 ¶
func Unzip3[T1, T2, T3 any](o Optional[tuple.Tuple3[T1, T2, T3]]) (Optional[T1], Optional[T2], Optional[T3])
Unzip3 converts an optional of 3-tuple to optionals of each elements.
func Unzip4 ¶
func Unzip4[T1, T2, T3, T4 any](o Optional[tuple.Tuple4[T1, T2, T3, T4]]) (Optional[T1], Optional[T2], Optional[T3], Optional[T4])
Unzip4 converts an optional of 4-tuple to optionals of each elements.
func Unzip5 ¶
func Unzip5[T1, T2, T3, T4, T5 any](o Optional[tuple.Tuple5[T1, T2, T3, T4, T5]]) (Optional[T1], Optional[T2], Optional[T3], Optional[T4], Optional[T5])
Unzip5 converts an optional of 5-tuple to optionals of each elements.
func Unzip6 ¶
func Unzip6[T1, T2, T3, T4, T5, T6 any](o Optional[tuple.Tuple6[T1, T2, T3, T4, T5, T6]]) (Optional[T1], Optional[T2], Optional[T3], Optional[T4], Optional[T5], Optional[T6])
Unzip6 converts an optional of 6-tuple to optionals of each elements.
func Unzip7 ¶
func Unzip7[T1, T2, T3, T4, T5, T6, T7 any](o Optional[tuple.Tuple7[T1, T2, T3, T4, T5, T6, T7]]) (Optional[T1], Optional[T2], Optional[T3], Optional[T4], Optional[T5], Optional[T6], Optional[T7])
Unzip7 converts an optional of 7-tuple to optionals of each elements.
func Unzip8 ¶
func Unzip8[T1, T2, T3, T4, T5, T6, T7, T8 any](o Optional[tuple.Tuple8[T1, T2, T3, T4, T5, T6, T7, T8]]) (Optional[T1], Optional[T2], Optional[T3], Optional[T4], Optional[T5], Optional[T6], Optional[T7], Optional[T8])
Unzip8 converts an optional of 8-tuple to optionals of each elements.
func Unzip9 ¶
func Unzip9[T1, T2, T3, T4, T5, T6, T7, T8, T9 any](o Optional[tuple.Tuple9[T1, T2, T3, T4, T5, T6, T7, T8, T9]]) (Optional[T1], Optional[T2], Optional[T3], Optional[T4], Optional[T5], Optional[T6], Optional[T7], Optional[T8], Optional[T9])
Unzip9 converts an optional of 9-tuple to optionals of each elements.
Types ¶
type Optional ¶
type Optional[T any] struct { // contains filtered or unexported fields }
Optional is an optional of T. Zero value equals None[T]()
func Map ¶
Example ¶
package main import ( "fmt" "github.com/shogo82148/hi/optional" ) func main() { v := optional.New(10) w := optional.Map(v, func(v int) string { return fmt.Sprintf("%x", v) }) fmt.Println(w.GetOrZero()) }
Output: a
func Zip10 ¶
func Zip10[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10 any](o1 Optional[T1], o2 Optional[T2], o3 Optional[T3], o4 Optional[T4], o5 Optional[T5], o6 Optional[T6], o7 Optional[T7], o8 Optional[T8], o9 Optional[T9], o10 Optional[T10]) Optional[tuple.Tuple10[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]]
Zip10 returns an optional of valid 10-tuples, if all of arguments are valid. Otherwise, one or more arguments are not valid, it returns none
func Zip11 ¶
func Zip11[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11 any](o1 Optional[T1], o2 Optional[T2], o3 Optional[T3], o4 Optional[T4], o5 Optional[T5], o6 Optional[T6], o7 Optional[T7], o8 Optional[T8], o9 Optional[T9], o10 Optional[T10], o11 Optional[T11]) Optional[tuple.Tuple11[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11]]
Zip11 returns an optional of valid 11-tuples, if all of arguments are valid. Otherwise, one or more arguments are not valid, it returns none
func Zip12 ¶
func Zip12[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12 any](o1 Optional[T1], o2 Optional[T2], o3 Optional[T3], o4 Optional[T4], o5 Optional[T5], o6 Optional[T6], o7 Optional[T7], o8 Optional[T8], o9 Optional[T9], o10 Optional[T10], o11 Optional[T11], o12 Optional[T12]) Optional[tuple.Tuple12[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12]]
Zip12 returns an optional of valid 12-tuples, if all of arguments are valid. Otherwise, one or more arguments are not valid, it returns none
func Zip13 ¶
func Zip13[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13 any](o1 Optional[T1], o2 Optional[T2], o3 Optional[T3], o4 Optional[T4], o5 Optional[T5], o6 Optional[T6], o7 Optional[T7], o8 Optional[T8], o9 Optional[T9], o10 Optional[T10], o11 Optional[T11], o12 Optional[T12], o13 Optional[T13]) Optional[tuple.Tuple13[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13]]
Zip13 returns an optional of valid 13-tuples, if all of arguments are valid. Otherwise, one or more arguments are not valid, it returns none
func Zip14 ¶
func Zip14[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14 any](o1 Optional[T1], o2 Optional[T2], o3 Optional[T3], o4 Optional[T4], o5 Optional[T5], o6 Optional[T6], o7 Optional[T7], o8 Optional[T8], o9 Optional[T9], o10 Optional[T10], o11 Optional[T11], o12 Optional[T12], o13 Optional[T13], o14 Optional[T14]) Optional[tuple.Tuple14[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14]]
Zip14 returns an optional of valid 14-tuples, if all of arguments are valid. Otherwise, one or more arguments are not valid, it returns none
func Zip15 ¶
func Zip15[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15 any](o1 Optional[T1], o2 Optional[T2], o3 Optional[T3], o4 Optional[T4], o5 Optional[T5], o6 Optional[T6], o7 Optional[T7], o8 Optional[T8], o9 Optional[T9], o10 Optional[T10], o11 Optional[T11], o12 Optional[T12], o13 Optional[T13], o14 Optional[T14], o15 Optional[T15]) Optional[tuple.Tuple15[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15]]
Zip15 returns an optional of valid 15-tuples, if all of arguments are valid. Otherwise, one or more arguments are not valid, it returns none
func Zip16 ¶
func Zip16[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16 any](o1 Optional[T1], o2 Optional[T2], o3 Optional[T3], o4 Optional[T4], o5 Optional[T5], o6 Optional[T6], o7 Optional[T7], o8 Optional[T8], o9 Optional[T9], o10 Optional[T10], o11 Optional[T11], o12 Optional[T12], o13 Optional[T13], o14 Optional[T14], o15 Optional[T15], o16 Optional[T16]) Optional[tuple.Tuple16[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16]]
Zip16 returns an optional of valid 16-tuples, if all of arguments are valid. Otherwise, one or more arguments are not valid, it returns none
func Zip2 ¶
Zip2 returns an optional of valid 2-tuples, if all of arguments are valid. Otherwise, one or more arguments are not valid, it returns none
Example ¶
package main import ( "fmt" "github.com/shogo82148/hi/optional" ) func main() { opt := optional.Zip2(optional.New(1), optional.New("one")) fmt.Println(opt.GetOrZero()) }
Output: (1, one)
func Zip3 ¶
func Zip3[T1, T2, T3 any](o1 Optional[T1], o2 Optional[T2], o3 Optional[T3]) Optional[tuple.Tuple3[T1, T2, T3]]
Zip3 returns an optional of valid 3-tuples, if all of arguments are valid. Otherwise, one or more arguments are not valid, it returns none
func Zip4 ¶
func Zip4[T1, T2, T3, T4 any](o1 Optional[T1], o2 Optional[T2], o3 Optional[T3], o4 Optional[T4]) Optional[tuple.Tuple4[T1, T2, T3, T4]]
Zip4 returns an optional of valid 4-tuples, if all of arguments are valid. Otherwise, one or more arguments are not valid, it returns none
func Zip5 ¶
func Zip5[T1, T2, T3, T4, T5 any](o1 Optional[T1], o2 Optional[T2], o3 Optional[T3], o4 Optional[T4], o5 Optional[T5]) Optional[tuple.Tuple5[T1, T2, T3, T4, T5]]
Zip5 returns an optional of valid 5-tuples, if all of arguments are valid. Otherwise, one or more arguments are not valid, it returns none
func Zip6 ¶
func Zip6[T1, T2, T3, T4, T5, T6 any](o1 Optional[T1], o2 Optional[T2], o3 Optional[T3], o4 Optional[T4], o5 Optional[T5], o6 Optional[T6]) Optional[tuple.Tuple6[T1, T2, T3, T4, T5, T6]]
Zip6 returns an optional of valid 6-tuples, if all of arguments are valid. Otherwise, one or more arguments are not valid, it returns none
func Zip7 ¶
func Zip7[T1, T2, T3, T4, T5, T6, T7 any](o1 Optional[T1], o2 Optional[T2], o3 Optional[T3], o4 Optional[T4], o5 Optional[T5], o6 Optional[T6], o7 Optional[T7]) Optional[tuple.Tuple7[T1, T2, T3, T4, T5, T6, T7]]
Zip7 returns an optional of valid 7-tuples, if all of arguments are valid. Otherwise, one or more arguments are not valid, it returns none
func Zip8 ¶
func Zip8[T1, T2, T3, T4, T5, T6, T7, T8 any](o1 Optional[T1], o2 Optional[T2], o3 Optional[T3], o4 Optional[T4], o5 Optional[T5], o6 Optional[T6], o7 Optional[T7], o8 Optional[T8]) Optional[tuple.Tuple8[T1, T2, T3, T4, T5, T6, T7, T8]]
Zip8 returns an optional of valid 8-tuples, if all of arguments are valid. Otherwise, one or more arguments are not valid, it returns none
func Zip9 ¶
func Zip9[T1, T2, T3, T4, T5, T6, T7, T8, T9 any](o1 Optional[T1], o2 Optional[T2], o3 Optional[T3], o4 Optional[T4], o5 Optional[T5], o6 Optional[T6], o7 Optional[T7], o8 Optional[T8], o9 Optional[T9]) Optional[tuple.Tuple9[T1, T2, T3, T4, T5, T6, T7, T8, T9]]
Zip9 returns an optional of valid 9-tuples, if all of arguments are valid. Otherwise, one or more arguments are not valid, it returns none
func (Optional[T]) FilterFalse ¶
func (Optional[T]) Get ¶
func (v Optional[T]) Get() T
Get returns the value of v if v is valid. Otherwise it panics.
func (Optional[T]) GetOr ¶
func (v Optional[T]) GetOr(defaults T) T
Get returns the value of v if v is valid. Otherwise it returns defaults.
func (Optional[T]) GetOrFunc ¶
func (v Optional[T]) GetOrFunc(f func() T) T
GetOrFunc returns the value of v if v is valid. Otherwise it calls f and returns its result.