Use the generic contains/index from slices instead of our custom one
This commit is contained in:
parent
5520a75bba
commit
7ce83e7fd0
@ -16,6 +16,8 @@ import (
|
|||||||
"kitty/tools/tui/loop"
|
"kitty/tools/tui/loop"
|
||||||
"kitty/tools/utils"
|
"kitty/tools/utils"
|
||||||
"kitty/tools/utils/images"
|
"kitty/tools/utils/images"
|
||||||
|
|
||||||
|
"golang.org/x/exp/slices"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ = fmt.Print
|
var _ = fmt.Print
|
||||||
@ -144,13 +146,13 @@ func (self *Output) assign_mime_type(available_mimes []string, aliases map[strin
|
|||||||
self.remote_mime_type = "."
|
self.remote_mime_type = "."
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if utils.Contains(available_mimes, self.mime_type) {
|
if slices.Contains(available_mimes, self.mime_type) {
|
||||||
self.remote_mime_type = self.mime_type
|
self.remote_mime_type = self.mime_type
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if len(aliases[self.mime_type]) > 0 {
|
if len(aliases[self.mime_type]) > 0 {
|
||||||
for _, alias := range aliases[self.mime_type] {
|
for _, alias := range aliases[self.mime_type] {
|
||||||
if utils.Contains(available_mimes, alias) {
|
if slices.Contains(available_mimes, alias) {
|
||||||
self.remote_mime_type = alias
|
self.remote_mime_type = alias
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@ -120,19 +120,6 @@ func Min[T constraints.Ordered](a T, items ...T) (ans T) {
|
|||||||
return ans
|
return ans
|
||||||
}
|
}
|
||||||
|
|
||||||
func Index[T comparable](haystack []T, needle T) int {
|
|
||||||
for i, x := range haystack {
|
|
||||||
if x == needle {
|
|
||||||
return i
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return -1
|
|
||||||
}
|
|
||||||
|
|
||||||
func Contains[T comparable](haystack []T, needle T) bool {
|
|
||||||
return Index(haystack, needle) > -1
|
|
||||||
}
|
|
||||||
|
|
||||||
// Keys returns the keys of the map m.
|
// Keys returns the keys of the map m.
|
||||||
// The keys will be an indeterminate order.
|
// The keys will be an indeterminate order.
|
||||||
func Keys[M ~map[K]V, K comparable, V any](m M) []K {
|
func Keys[M ~map[K]V, K comparable, V any](m M) []K {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user