The hard part of is trying to simultaneously have hard to misuse APIs and no additional performance penalty (however small). If you relax either of those goals (is it really a problem if you call that method through a v-table? Is using interior mutability for that config flag going to affect anything?), then becomes much easier to write.

0

If you have a fediverse account, you can quote this note from your own instance. Search https://hachyderm.io/users/ekuber/statuses/115554937980739384 on your instance and quote it. (Note that quoting is not supported in Mastodon.)