-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
70 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package jaws | ||
|
||
import "fmt" | ||
|
||
type errNotHashableType struct { | ||
s string | ||
} | ||
|
||
func (e errNotHashableType) Error() string { | ||
return fmt.Sprintf("not hashable type %s", e.s) | ||
} | ||
|
||
func (errNotHashableType) Is(other error) bool { | ||
return other == ErrIllegalTagType | ||
} | ||
|
||
func newErrNotHashableType(tag any) error { | ||
return errNotHashableType{ | ||
s: fmt.Sprintf("%T", tag), | ||
} | ||
} | ||
|
||
var ErrNotHashableType = errNotHashableType{} | ||
|
||
func checkHashable(tag any) (err error) { | ||
defer func() { | ||
if recover() != nil { | ||
err = newErrNotHashableType(tag) | ||
} | ||
}() | ||
tmp := map[any]struct{}{} | ||
tmp[tag] = struct{}{} | ||
return | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
package jaws | ||
|
||
type Container interface { | ||
// JawsContains must return a slice of UI objects. The slice contents must not be modified after returning it. | ||
// JawsContains must return a slice of hashable UI objects. The slice contents must not be modified after returning it. | ||
JawsContains(e *Element) (contents []UI) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters