github.com/15mga/kiwi@v0.0.2-0.20240324021231-b95d5c3ac751/util/slice.go (about)

     1  package util
     2  
     3  func ArgsToSlc[T any](args ...T) []T {
     4  	return args
     5  }
     6  
     7  func SplitSlc1[T any](slc []any) T {
     8  	return slc[0].(T)
     9  }
    10  
    11  func SplitSlc2[T1, T2 any](slc []any) (T1, T2) {
    12  	return slc[0].(T1), slc[1].(T2)
    13  }
    14  
    15  func SplitSlc3[T1, T2, T3 any](slc []any) (T1, T2, T3) {
    16  	return slc[0].(T1), slc[1].(T2), slc[2].(T3)
    17  }
    18  
    19  func SplitSlc4[T1, T2, T3, T4 any](slc []any) (T1, T2, T3, T4) {
    20  	return slc[0].(T1), slc[1].(T2), slc[2].(T3), slc[3].(T4)
    21  }
    22  
    23  func SplitSlc5[T1, T2, T3, T4, T5 any](slc []any) (T1, T2, T3, T4, T5) {
    24  	return slc[0].(T1), slc[1].(T2), slc[2].(T3), slc[3].(T4), slc[4].(T5)
    25  }
    26  
    27  func SplitSlc6[T1, T2, T3, T4, T5, T6 any](slc []any) (T1, T2, T3, T4, T5, T6) {
    28  	return slc[0].(T1), slc[1].(T2), slc[2].(T3), slc[3].(T4), slc[4].(T5), slc[5].(T6)
    29  }
    30  
    31  func SplitSlc7[T1, T2, T3, T4, T5, T6, T7 any](slc []any) (T1, T2, T3, T4, T5, T6, T7) {
    32  	return slc[0].(T1), slc[1].(T2), slc[2].(T3), slc[3].(T4), slc[4].(T5), slc[5].(T6), slc[6].(T7)
    33  }
    34  
    35  func SplitSlc8[T1, T2, T3, T4, T5, T6, T7, T8 any](slc []any) (T1, T2, T3, T4, T5, T6, T7, T8) {
    36  	return slc[0].(T1), slc[1].(T2), slc[2].(T3), slc[3].(T4), slc[4].(T5), slc[5].(T6), slc[6].(T7), slc[7].(T8)
    37  }