Rust: how to make a global function that is only callable once?
My goal is to make this program fail to compile, using only the type system:
pow can be called endlessly, I don't want that.
I tried the following, but it wasn't working without an implementation of the
Since I don't know how to use traits, this failed too:
My real use case is that I have a function which creates a hook that must not be created more than once, and using runtime boolean mutation, checking, and branching could introduce bugs, along with increased code size and unnecessay runtime overhead, where the second call should be prevented at compile-time anyway.
Does anyone know how this could be done?