feat(ksuid): add Equal and IsZero for ApplyInterfacePtr
StringKSUID and BinaryKSUID now implement ApplyInterface with nil-nil equality semantics, enabling ApplyInterfacePtr in patch logic. Adds nil sentinel vars and tests. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -15,6 +15,20 @@ type BinaryKSUID struct {
|
||||
ksuid.KSUID
|
||||
}
|
||||
|
||||
// NilBinaryKSUID is the zero/nil BinaryKSUID value.
|
||||
var NilBinaryKSUID = BinaryKSUID{KSUID: ksuid.Nil}
|
||||
|
||||
// Equal reports whether two BinaryKSUID values represent the same identifier,
|
||||
// treating two nil values as equal. Implements [ApplyInterface].
|
||||
func (b BinaryKSUID) Equal(rh BinaryKSUID) bool {
|
||||
return equalKSUID(b.KSUID, rh.KSUID)
|
||||
}
|
||||
|
||||
// IsZero reports whether b is nil. Implements [ApplyInterface].
|
||||
func (b BinaryKSUID) IsZero() bool {
|
||||
return b.IsNil()
|
||||
}
|
||||
|
||||
// NewBinaryKSUID generates a new BinaryKSUID.
|
||||
func NewBinaryKSUID() BinaryKSUID {
|
||||
return BinaryKSUID{KSUID: ksuid.New()}
|
||||
|
||||
Reference in New Issue
Block a user