1 You're trying to write an inherent implementation for something which isn't a
2 struct nor an enum. Erroneous code example:
5 impl (u8, u8) { // error: no base type found for inherent implementation
6 fn get_state(&self) -> String {
12 To fix this error, please implement a trait on the type or wrap it in a struct.
16 // we create a trait here
17 trait LiveLongAndProsper {
18 fn get_state(&self) -> String;
21 // and now you can implement it on (u8, u8)
22 impl LiveLongAndProsper for (u8, u8) {
23 fn get_state(&self) -> String {
24 "He's dead, Jim!".to_owned()
29 Alternatively, you can create a newtype. A newtype is a wrapping tuple-struct.
30 For example, `NewType` is a newtype over `Foo` in `struct NewType(Foo)`.
34 struct TypeWrapper((u8, u8));
37 fn get_state(&self) -> String {
38 "Fascinating!".to_owned()