1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00
v/vlib/v/parser/tests/interface_mutability_receiver.vv

26 lines
500 B
V

// fixes https://github.com/vlang/v/issues/1081 and https://github.com/vlang/v/issues/7338, code by https://github.com/nedpals
// copied from https://github.com/vlang/v/issues/7338
struct Doggo {
pub mut:
name string
}
fn (mut d Doggo) set_name(name string) {
d.name = name
}
interface Animal {
set_name(name string)
}
fn set_animal_name(a Animal, name string) {
a.set_name(name)
}
fn main() {
dog := Doggo{'Doggo'}
println(dog.name)
set_animal_name(dog, 'Pupper')
println(dog.name)
}