Add proptools.Slice am: a962edf763
Original change: https://android-review.googlesource.com/c/platform/build/blueprint/+/3003509 Change-Id: Ic74a65ea7cf8a49900120682fa94460815acd278 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
commit
ab9b28700a
1 changed files with 9 additions and 0 deletions
|
@ -105,6 +105,15 @@ func String(s *string) string {
|
|||
return StringDefault(s, "")
|
||||
}
|
||||
|
||||
// Slice takes a pointer to a slice and returns the value of the slice if the pointer is non-nil,
|
||||
// or a nil slice.
|
||||
func Slice[T any](s *[]T) []T {
|
||||
if s != nil {
|
||||
return *s
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// IntDefault takes a pointer to an int64 and returns the value pointed to by the pointer cast to int
|
||||
// if it is non-nil, or def if the pointer is nil.
|
||||
func IntDefault(i *int64, def int) int {
|
||||
|
|
Loading…
Reference in a new issue