tgbot_misaka_5882f7/utils/utils.go

19 lines
295 B
Go

package utils
func WaitFor(fn func()) <-chan struct{} {
ch := make(chan struct{})
go func() {
defer close(ch)
fn()
}()
return ch
}
func ToLookupMap[T comparable](s []T) map[T]struct{} {
m := make(map[T]struct{}, len(s))
for _, item := range s {
m[item] = struct{}{}
}
return m
}