Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 1 of 1 for NewSetFromSlice (0.23 sec)

  1. src/internal/types/testdata/fixedbugs/issue51257.go

    }
    
    
    // example from issue
    
    type Set[T comparable] map[T]struct{}
    
    func NewSetFromSlice[T comparable](items []T) *Set[T] {
    	s := Set[T]{}
    
    	for _, item := range items {
    		s[item] = struct{}{}
    	}
    
    	return &s
    }
    
    type T struct{ x any }
    
    func main() {
    	NewSetFromSlice([]T{
    		{"foo"},
    		{5},
    	})
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Tue Jan 17 19:56:37 UTC 2023
    - 766 bytes
    - Viewed (0)
Back to top