Skip to content

Commit cbaa98b

Browse files
robyoderdeckarep
authored andcommitted
Fix PowerSet return values
Previously, calling `PowerSet()` on a `threadSafeSet` would return a `threadUnsafeSet` of `threadUnsafeSet`s. Now it returns a `threadSafeSet` of `threadSafeSet`s.
1 parent 82e95d2 commit cbaa98b

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

threadsafe.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,14 @@ func (set *threadSafeSet) String() string {
226226

227227
func (set *threadSafeSet) PowerSet() Set {
228228
set.RLock()
229-
ret := set.s.PowerSet()
229+
unsafePowerSet := set.s.PowerSet().(*threadUnsafeSet)
230230
set.RUnlock()
231+
232+
ret := &threadSafeSet{s: newThreadUnsafeSet()}
233+
for subset := range unsafePowerSet.Iter() {
234+
unsafeSubset := subset.(*threadUnsafeSet)
235+
ret.Add(&threadSafeSet{s: *unsafeSubset})
236+
}
231237
return ret
232238
}
233239

0 commit comments

Comments
 (0)