2 ms·
Oh. I wonder if the Display trait implementation can be enforced to have no side effects (beside allocation).
by nine_k 5y ago
Oh. I wonder if the Display trait implementation can be enforced to have no side effects (beside allocation).
- sidit77 5y agoWhen implementing Display you only get access to an immutable reference to self, so the only possibly side effects are writes to global variables.
- bluejekyll 5y agoThat depends on what Self contains. Using the Cell types and some of the other inner mutating types, it is possible to change the interior state of self even behind a shared reference. Additionally, with unsafe it’s also possible. This is in response to “the only possible” statement. Of course, doing so is not advisable.