Protocol std::cmp::DefaultEquatable
Mixin to provide a default implementation of Equatable for a type.
This mixin provides a default implementation of equals for a type. If the type is a
struct, it will compare each field as with the ==
operator. If the type is an enum, it will
compare the underlying value using the ==
operator.
If any field is not equatable, this will result in a compilation error.
Example
struct FullName { first: &[u8], last: &[u8] }
impl FullName {
use std::cmp::DefaultEquatable;
mixin DefaultEquatable<FullName>;
}
assert_eq!(
FullName { first: "John", last: "Doe" },
FullName { first: "John", last: "Doe" }
);
assert_ne!(
FullName { first: "John", last: "Doe" },
FullName { first: "John", last: "Smith" }
);
Run this example
Provided methods
-
Returns
false
if arguments are equal,true
otherwise