1 An unary operator was used on a type which doesn't implement it.
3 Example of erroneous code:
11 !Question::Yes; // error: cannot apply unary operator `!` to type `Question`
14 In this case, `Question` would need to implement the `std::ops::Not` trait in
15 order to be able to use `!` on it. Let's implement it:
25 // We implement the `Not` trait on the enum.
26 impl Not for Question {
29 fn not(self) -> bool {
31 Question::Yes => false, // If the `Answer` is `Yes`, then it
33 Question::No => true, // And here we do the opposite.
38 assert_eq!(!Question::Yes, false);
39 assert_eq!(!Question::No, true);