github.com/searKing/golang/go@v1.2.117/exp/types/any.go (about)

     1  // Copyright 2023 The searKing Author. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package types
     6  
     7  // Any returns its argument v or nil if and only if v is a typed nil or an untyped nil.
     8  // For example, if v was created by set with `var p *int` or calling [Any]((*int)(nil)),
     9  // [Any] returns nil.
    10  func Any[T any](v *T) any {
    11  	if v == nil {
    12  		return nil
    13  	}
    14  	return v
    15  }