zlacker

[parent] [thread] 1 comments
1. eptcyk+(OP)[view] [source] 2025-08-22 17:04:58
Go allows deferring an implementation of an interface to a member of a type. It is somewhat unintuitive, and I think the field has to be an unnamed one.

Similarly, if a field implements a trait in Rust, you can expose it via `AsRef` and `AsMutRef`, just return a reference to it.

These are not ideal tools, and I find the Go solution rather unintuitive, but they solve the problems that I would've solved with inheritance in other languages. I rarely use them.

replies(1): >>zac23o+Ub
2. zac23o+Ub[view] [source] 2025-08-22 18:09:35
>>eptcyk+(OP)
Thanks. I had been searching for this for a project in the past and couldn't find it in Go or Rust. Before posting, I asked chatgpt, and he said it wasn't possible...
[go to top]