The worst way to run your code only once: definitely-only-once
I have made a crate (in jest) to run code only once, by using some self modifying assembly. It's horribly unsafe, compiles unpredictably and should definitely not be used.
But it does serve as a minimal example of rewriting assembly instructions from code altering the behaviour of a program.
Let me know what you think, and please do not use it.