mirror of
https://github.com/protocolbuffers/protobuf-go.git
synced 2025-03-10 16:14:39 +00:00
proto: document Equal behavior of invalid messages
The doc comment of proto.Equal now explicitly describes the behavior in the case when one message is valid and other is invalid. Change-Id: Ifeba40277c7da25193d46ad496e910f9b63eb795 Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/464275 Reviewed-by: Joseph Tsai <joetsai@digital-static.net> Reviewed-by: Chressie Himpel <chressie@google.com>
This commit is contained in:
parent
358fe40267
commit
e831c33179
@ -31,8 +31,13 @@ import (
|
|||||||
// - Maps are equal if they have the same set of keys and
|
// - Maps are equal if they have the same set of keys and
|
||||||
// the corresponding value for each key is equal.
|
// the corresponding value for each key is equal.
|
||||||
//
|
//
|
||||||
// If two messages marshal to the same bytes under deterministic serialization,
|
// An invalid message is not equal to a valid message.
|
||||||
// then Equal is guaranteed to report true.
|
// An invalid message is only equal to another invalid message of the
|
||||||
|
// same type. An invalid message often corresponds to a nil pointer
|
||||||
|
// of the concrete message type. For example, (*pb.M)(nil) is not equal
|
||||||
|
// to &pb.M{}.
|
||||||
|
// If two valid messages marshal to the same bytes under deterministic
|
||||||
|
// serialization, then Equal is guaranteed to report true.
|
||||||
func Equal(x, y Message) bool {
|
func Equal(x, y Message) bool {
|
||||||
if x == nil || y == nil {
|
if x == nil || y == nil {
|
||||||
return x == nil && y == nil
|
return x == nil && y == nil
|
||||||
|
Loading…
x
Reference in New Issue
Block a user