Want: proc macro to add getter / setter properties to fields. #[derive(Access)] pub struct Foo { #[access(get, get_mut, set)] bar: bool, } let mut foo = Foo::default(); http://foo.bar (); // false foo.set_bar(true); http://foo.bar (); // true
Could you elaborate? Why is it an anti-pattern? How else would you for example implement a field that should only allow for read-only access?
-
-
I have no good arguments, just came quite far in rust without ever using them. Id rather make a whole struct mut or copy on right. That keeps the state changes clearer. Feels more like a the immutable data structure approache. Of course performance may speak against that too.
-
I doubt performance would be an issue here tbh — zero cost abstractions and all, haha. The difference here, I think, is that I'm trying to enforce a contract when defining a function, rather than using COW / mut at usage time. That way usage becomes less easy to mess up

- 3 more replies
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.