MCPcopy Index your code
hub / github.com/cortexproject/cortex / FromLabelAdaptersToLabels

Function FromLabelAdaptersToLabels

pkg/cortexpb/compat.go:62–64  ·  view source on GitHub ↗

FromLabelAdaptersToLabels casts []LabelAdapter to labels.Labels. It uses unsafe, but as LabelAdapter == labels.Label this should be safe. This allows us to use labels.Labels directly in protos. Note: while resulting labels.Labels is supposedly sorted, this function doesn't enforce that. If input is

(ls []LabelAdapter)

Source from the content-addressed store, hash-verified

60// Note: while resulting labels.Labels is supposedly sorted, this function
61// doesn't enforce that. If input is not sorted, output will be wrong.
62func FromLabelAdaptersToLabels(ls []LabelAdapter) labels.Labels {
63 return *(*labels.Labels)(unsafe.Pointer(&ls))
64}
65
66// FromLabelAdaptersToLabelsWithCopy converts []LabelAdapter to labels.Labels.
67// Do NOT use unsafe to convert between data types because this function may

Calls

no outgoing calls