Skip to content

Commit

Permalink
feat(sets): fix type alias
Browse files Browse the repository at this point in the history
  • Loading branch information
leaxoy committed Jan 3, 2024
1 parent 6993451 commit 0f99d12
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions sets/set.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func FromMapKeys[E comparable, V any, M ~map[E]V](m M) HashSet[E] {
return set
}

// FromIter create a HashSet from [Seq].
// FromIter create a HashSet from [iter.Seq].
func FromIter[E comparable](s iter.Seq[E]) HashSet[E] {
set := New[E]()
set.AddIter(s)
Expand Down Expand Up @@ -96,7 +96,11 @@ func (self HashSet[E]) IsEmpty() bool {
}

func (self HashSet[E]) ToMap() map[E]struct{} {
return self.Clone().inner
m := make(map[E]struct{})
for k := range self.inner {
m[k] = struct{}{}
}
return m
}

// Clone returns a copy of the set.
Expand Down

0 comments on commit 0f99d12

Please sign in to comment.