@@ -39,18 +39,18 @@ type TestingCleanup interface {
3939// type TPtr that references the allocated object. TPtr is either *T or has *T
4040// as its underlying type (i.e, defined as "type Foo *Bar", where TPtr = Foo
4141// and T = Bar). The returned reference or any other reference to the allocated
42- // object is considered a placeholder reference: when cmp.Equal is invoked
43- // with the placeholders.Comparer option, a placeholder reference is considered
44- // to be equal to any other object, regardless of types or values.
42+ // object is considered a placeholder reference: when cmp.Equal or cmp.Diff is
43+ // invoked with the placeholders.Ignore option, a placeholder reference is
44+ // considered to be equal to any other object, regardless of types or values.
4545//
4646// Only pointers to the allocated object are considered placeholders and not
4747// the object itself (see examples below).
4848//
4949// The second type parameter (T) can always be inferred from the first one
5050// (TPtr) and does not need to be explicitly specified.
5151//
52- // The only parameter (t) can of type *testing.T, *testing.B, or any other type
53- // with a function Cleanup with a similar semantic and it ensures that the
52+ // The only parameter (t) can be of type *testing.T, *testing.B, or any other
53+ // type with a function Cleanup with a similar semantic. It ensures that the
5454// resources allocated to keep track of the placeholders are eventually
5555// reclaimed (e.g., when t is of type *testing.T, they are reclaimed upon the
5656// completion of the test).
@@ -59,24 +59,24 @@ type TestingCleanup interface {
5959// helloString := "hello"
6060//
6161// // true
62- // cmp.Equal(placeholders.Make[*string](t), &helloString, placeholders.Comparer ())
62+ // cmp.Equal(placeholders.Make[*string](t), &helloString, placeholders.Ignore ())
6363//
6464// placeholder := placeholders.Make[*string](t)
6565// anotherRef := &(*placeholder)
6666//
6767// // true, any reference to the allocated object is a placeholder
68- // cmp.Equal(anotherRef, &helloString, placeholders.Comparer ())
68+ // cmp.Equal(anotherRef, &helloString, placeholders.Ignore ())
6969//
7070// // false, the allocated object itself is not a placeholder
71- // cmp.Equal(*placeholder, "hello", placeholders.Comparer ())
71+ // cmp.Equal(*placeholder, "hello", placeholders.Ignore ())
7272//
7373// type Foo struct {SPtr *string; S string}
7474//
7575// // true, it works with struct fields and embedded types as well!
76- // cmp.Equal(Foo{placeholders.Make[*string](t), "world"}, Foo{&helloString, "world"}, placeholders.Comparer ())
76+ // cmp.Equal(Foo{placeholders.Make[*string](t), "world"}, Foo{&helloString, "world"}, placeholders.Ignore ())
7777//
7878// // false, non-placeholder fields differ
79- // cmp.Equal(Foo{placeholders.Make[*string](t), "earthlings"}, Foo{&helloString, "world"}, placeholders.Comparer ())
79+ // cmp.Equal(Foo{placeholders.Make[*string](t), "earthlings"}, Foo{&helloString, "world"}, placeholders.Ignore ())
8080func Make [TPtr ~ * T , T any ](t TestingCleanup ) TPtr {
8181 placeholderManagerInit .Do (func () {
8282 // placeholderManager.placeholdersMx doesn't need initialization.
@@ -138,12 +138,11 @@ func IsPlaceholder(obj any) bool {
138138
139139func equateAlways (_ , _ interface {}) bool { return true }
140140
141- // Comparer returns a cmp.Comparer option that determines a placeholder to be
142- // equal with any other object (regardless of types and values).
143- func Comparer () cmp.Option {
141+ // Ignore returns a cmp.Ignore option that ignores all placeholders.
142+ func Ignore () cmp.Option {
144143 filter := func (a , b any ) bool {
145144 return IsPlaceholder (a ) || IsPlaceholder (b )
146145 }
147146
148- return cmp .FilterValues (filter , cmp .Comparer ( equateAlways ))
147+ return cmp .FilterValues (filter , cmp .Ignore ( ))
149148}
0 commit comments