Functional Macro
Background
This macro is aimed to help enforce pure functions.
While it does have known limitations (see below), we still believe it provides value to help keep mutation in check.
How does it work?
- We parse each
functionarguments and check if they aremutable(&mut). - We rewrite the
functionas with an internalmoduleto preventglobalsusage.
Original:
Rewrite:
Known Limitations
-
Any
structthat internally hidesmutabilitywill not be caught by thismacro.For example, the following
structwill not be caught by thismacro:Arc<Mutex<T>>.Cell<T>.RefCell<T>.RwLock<T>.UnsafeCell<T>.
All of these wrap
UnsafeCell<T>internally, which is why they are not caught by thismacro. -
asyncfunctions are not supported. -
&selfand&mut selfare not supported.