| 1 | pub interface IObject { |
| 2 | mut: |
| 3 | do_stuff() |
| 4 | do_something_with_int(int) |
| 5 | do_something_with_string(string) |
| 6 | } |
| 7 | |
| 8 | pub struct BaseObject { |
| 9 | mut: |
| 10 | some_attr int |
| 11 | } |
| 12 | |
| 13 | pub fn (mut base BaseObject) do_stuff() {} |
| 14 | |
| 15 | pub fn (mut base BaseObject) do_something_with_int(n int) {} |
| 16 | |
| 17 | pub fn (mut base BaseObject) do_something_with_string(s string) {} |
| 18 | |
| 19 | pub fn (mut base BaseObject) method_thats_available_to_all_object() {} |
| 20 | |
| 21 | pub struct GameObject { |
| 22 | BaseObject |
| 23 | pub mut: |
| 24 | some_attr_for_game int |
| 25 | } |
| 26 | |
| 27 | fn test_interface_method_using_struct_embed() { |
| 28 | mut common_object := []IObject{} |
| 29 | common_object << GameObject{} |
| 30 | println(common_object) |
| 31 | assert common_object.len == 1 |
| 32 | } |
| 33 | |