mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-18 22:44:50 +02:00
Make a couple of other Set API functions nil-safe
This commit is contained in:
@@ -84,7 +84,7 @@ func (self *Set[T]) Intersect(other *Set[T]) (ans *Set[T]) {
|
||||
func (self *Set[T]) Subtract(other *Set[T]) (ans *Set[T]) {
|
||||
ans = NewSet[T](self.Len())
|
||||
for x := range self.items {
|
||||
if !other.Has(x) {
|
||||
if other == nil || !other.Has(x) {
|
||||
ans.items[x] = struct{}{}
|
||||
}
|
||||
}
|
||||
@@ -92,6 +92,9 @@ func (self *Set[T]) Subtract(other *Set[T]) (ans *Set[T]) {
|
||||
}
|
||||
|
||||
func (self *Set[T]) IsSubsetOf(other *Set[T]) bool {
|
||||
if other == nil {
|
||||
return self.Len() == 0
|
||||
}
|
||||
for x := range self.items {
|
||||
if !other.Has(x) {
|
||||
return false
|
||||
|
||||
Reference in New Issue
Block a user