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 StringKSUID struct {
|
||||
ksuid.KSUID
|
||||
}
|
||||
|
||||
// NilStringKSUID is the zero/nil StringKSUID value.
|
||||
var NilStringKSUID = StringKSUID{KSUID: ksuid.Nil}
|
||||
|
||||
// Equal reports whether two StringKSUID values represent the same identifier,
|
||||
// treating two nil values as equal. Implements [ApplyInterface].
|
||||
func (s StringKSUID) Equal(rh StringKSUID) bool {
|
||||
return equalKSUID(s.KSUID, rh.KSUID)
|
||||
}
|
||||
|
||||
// IsZero reports whether s is nil. Implements [ApplyInterface].
|
||||
func (s StringKSUID) IsZero() bool {
|
||||
return s.IsNil()
|
||||
}
|
||||
|
||||
// NewStringKSUID generates a new StringKSUID.
|
||||
func NewStringKSUID() StringKSUID {
|
||||
return StringKSUID{KSUID: ksuid.New()}
|
||||
|
||||
Reference in New Issue
Block a user