MCPcopy Create free account
hub / github.com/google/gapid / toSlice

Function toSlice

core/data/slice/slice.go:177–185  ·  view source on GitHub ↗

toSlice returns the reflect.Value of v, turning it into a single element slice (of type sliceTy) if it isn't a slice already.

(v interface{}, sliceTy reflect.Type)

Source from the content-addressed store, hash-verified

175// toSlice returns the reflect.Value of v, turning it into a single element
176// slice (of type sliceTy) if it isn't a slice already.
177func toSlice(v interface{}, sliceTy reflect.Type) reflect.Value {
178 e := reflect.ValueOf(v)
179 if e.Kind() == reflect.Slice {
180 return e
181 }
182 s := reflect.MakeSlice(sliceTy, 1, 1)
183 s.Index(0).Set(e)
184 return s
185}

Callers 1

replaceFunction · 0.85

Calls 4

MakeSliceMethod · 0.80
KindMethod · 0.65
SetMethod · 0.65
IndexMethod · 0.65

Tested by

no test coverage detected