mirror of https://github.com/dapr/kit.git
33 lines
1.0 KiB
Go
33 lines
1.0 KiB
Go
/*
|
|
Copyright 2021 The Dapr Authors
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
you may not use this file except in compliance with the License.
|
|
You may obtain a copy of the License at
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
Unless required by applicable law or agreed to in writing, software
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
See the License for the specific language governing permissions and
|
|
limitations under the License.
|
|
*/
|
|
|
|
// Based on https://github.com/Azure/azure-sdk-for-go/blob/sdk/azcore/v1.1.1/sdk/azcore/to/to.go
|
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
// Licensed under the MIT License.
|
|
|
|
package ptr
|
|
|
|
// Of returns a pointer to the provided value.
|
|
func Of[T any](v T) *T {
|
|
return &v
|
|
}
|
|
|
|
// SliceOfPtrs returns a slice of *T from the specified values.
|
|
func SliceOfPtrs[T any](vv ...T) []*T {
|
|
slc := make([]*T, len(vv))
|
|
for i := range vv {
|
|
slc[i] = Of(vv[i])
|
|
}
|
|
return slc
|
|
}
|