Convenience method to access any member of a set

This commit is contained in:
Kovid Goyal
2025-05-15 21:40:06 +05:30
parent 9a543c2370
commit 429cff0a52

View File

@@ -73,6 +73,13 @@ func (self *Set[T]) Iterable() map[T]struct{} {
return self.items
}
func (self *Set[T]) Any() T {
for x := range self.items {
return x
}
panic("set is empty")
}
func (self *Set[T]) AsSlice() []T {
return Keys(self.items)
}