github.com/haraldrudell/parl@v0.4.176/pslices/resolve-slice.go (about)

     1  /*
     2  © 2022–present Harald Rudell <harald.rudell@gmail.com> (https://haraldrudell.github.io/haraldrudell/)
     3  ISC License
     4  */
     5  
     6  package pslices
     7  
     8  // ResolveSlice removes one level of indirection from a slice of pointers.
     9  func ResolveSlice[E any](slic []*E) (sList []E) {
    10  	length := len(slic)
    11  	if length == 0 {
    12  		return
    13  	}
    14  	sList = make([]E, length)
    15  	for i, e := range slic {
    16  		sList[i] = *e
    17  	}
    18  	return
    19  }