gear icon indicating copy to clipboard operation
gear copied to clipboard

Revert `self` mutability for `Environment` trait

Open breathx opened this issue 2 years ago • 0 comments

File Location(s)

gear/core/env.rs

Proposal

Our core written in style when we don't mind any blockchain logic and we should keep that way. Environment trait is just a behavior specified for some env, where that core used, so there is no reason to take &mut self for getters.

For example, fn source(&mut self) ... returns the source of the currently running message. It conceptually doesn't mutate anything, so it's signature should be fn source(&self) ... . https://github.com/gear-tech/gear/blob/85b21d04f94ac89a163e1ff06704b41364d5d444/core/src/env.rs#L97

breathx avatar May 04 '22 16:05 breathx