Re:Can you use a class in C?
by Waterluvian on Sunday August 13, 2023 @08:05AM
(#37109129)
This is why I like Rust’s associated functions concept. It is just functions and data. But with organization of clear relationships. “These functions act on these data.” (And a bit of syntactic sugar)
[ Parent
| on HN ]
One disadvantage here is taking the entire struct on each operation even if only a single part of it is needed. That can be much harder to deal with due to ownership rules (if &Mut self or all of self is taken). Free functions can be easier then.