1 Something other than a type has been used when one was expected.
3 Erroneous code examples:
10 fn oblivion() -> Dragon::Born { // error!
14 const HOBBIT: u32 = 2;
15 impl HOBBIT {} // error!
23 fn wizard(_: Wizard::Saruman); // error!
27 In all these errors, a type was expected. For example, in the first error, if
28 we want to return the `Born` variant from the `Dragon` enum, we must set the
29 function to return the enum and not its variant:
36 fn oblivion() -> Dragon { // ok!
41 In the second error, you can't implement something on an item, only on types.
42 We would need to create a new type if we wanted to do something similar:
45 struct Hobbit(u32); // we create a new type
47 const HOBBIT: Hobbit = Hobbit(2);
51 In the third case, we tried to only expect one variant of the `Wizard` enum,
52 which is not possible. To make this work, we need to using pattern matching
53 over the `Wizard` enum:
62 fn wizard(w: Wizard) { // ok!
67 _ => {} // ignore everything else