github.com/m4gshm/gollections@v0.0.13-0.20240331203319-a34a86e58a24/slice/clone/api.go (about)

     1  // Package clone provides slice clone aliases
     2  package clone
     3  
     4  import (
     5  	"github.com/m4gshm/gollections/convert/ptr"
     6  	"github.com/m4gshm/gollections/slice"
     7  )
     8  
     9  // Of is slice.Clone alias
    10  func Of[TS ~[]T, T any](elements TS) TS {
    11  	return slice.Clone(elements)
    12  }
    13  
    14  // Deep is slice.DeepClone alias
    15  func Deep[TS ~[]T, T any](elements TS, copier func(T) T) TS {
    16  	return slice.DeepClone(elements, copier)
    17  }
    18  
    19  // Ptr returns a pointer to a copy of the value pointed to by the 'p'
    20  func Ptr[T any](p *T) *T { return ptr.Of(*p) }