You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
struct A {
v: int,
}
fn find_a() -> Option<A> {
None
}
fn main() {
let a = find_a();
assert!(a.is_none());
assert_eq!(a, None); // Got too many irrelevant compile errors!
}
Compile errors:
<std macros>:6:23: 6:50 error: binary operation `==` cannot be applied to type `core::option::Option<A>`
<std macros>:6 if !((*given_val == *expected_val) &&
^~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 14:2 note: in expansion of assert_eq!
assert_eq_none.rs:12:2: 12:22 note: expansion site
<std macros>:9:56: 9:66 error: the trait `core::fmt::Show` is not implemented for the type `A`
<std macros>:9 (left: `{}`, right: `{}`)", *given_val, *expected_val)
^~~~~~~~~~
note: in expansion of format_args!
<std macros>:32:9: 33:6 note: expansion site
<std macros>:1:1: 34:2 note: in expansion of panic!
<std macros>:8:21: 10:18 note: expansion site
<std macros>:1:1: 14:2 note: in expansion of assert_eq!
assert_eq_none.rs:12:2: 12:22 note: expansion site
<std macros>:9:56: 9:66 note: the trait `core::fmt::Show` must be implemented because it is required by `core::fmt::Show::fmt`
<std macros>:9 (left: `{}`, right: `{}`)", *given_val, *expected_val)
^~~~~~~~~~
note: in expansion of format_args!
<std macros>:32:9: 33:6 note: expansion site
<std macros>:1:1: 34:2 note: in expansion of panic!
<std macros>:8:21: 10:18 note: expansion site
<std macros>:1:1: 14:2 note: in expansion of assert_eq!
assert_eq_none.rs:12:2: 12:22 note: expansion site
<std macros>:9:68: 9:81 error: the trait `core::fmt::Show` is not implemented for the type `A`
<std macros>:9 (left: `{}`, right: `{}`)", *given_val, *expected_val)
^~~~~~~~~~~~~
note: in expansion of format_args!
<std macros>:32:9: 33:6 note: expansion site
<std macros>:1:1: 34:2 note: in expansion of panic!
<std macros>:8:21: 10:18 note: expansion site
<std macros>:1:1: 14:2 note: in expansion of assert_eq!
assert_eq_none.rs:12:2: 12:22 note: expansion site
<std macros>:9:68: 9:81 note: the trait `core::fmt::Show` must be implemented because it is required by `core::fmt::Show::fmt`
<std macros>:9 (left: `{}`, right: `{}`)", *given_val, *expected_val)
^~~~~~~~~~~~~
note: in expansion of format_args!
<std macros>:32:9: 33:6 note: expansion site
<std macros>:1:1: 34:2 note: in expansion of panic!
<std macros>:8:21: 10:18 note: expansion site
<std macros>:1:1: 14:2 note: in expansion of assert_eq!
assert_eq_none.rs:12:2: 12:22 note: expansion site
<std macros>:7:23: 7:50 error: the trait `core::cmp::PartialEq` is not implemented for the type `A`
<std macros>:7 (*expected_val == *given_val)) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 14:2 note: in expansion of assert_eq!
assert_eq_none.rs:12:2: 12:22 note: expansion site
error: aborting due to 4 previous errors
Adding #[deriving(PartialEq,Eq,Show)] to struct A should resolve these compile errors.
The text was updated successfully, but these errors were encountered:
Compile errors:
Adding
#[deriving(PartialEq,Eq,Show)]
to struct A should resolve these compile errors.The text was updated successfully, but these errors were encountered: