macro_rules! select_once {
(
sig: fn($($arg:ident: $ArgTy:ty),*) -> $RetTy:ty,
init: $init:expr,
call: $call:expr,
) => { ... };
}Expand description
Call init once to choose an implementation, then use it for the rest of the program.
sigis the function type.initis an expression called at startup that chooses an implementation and returns a function pointer.callis an expression to call a function returned byinit, encapsulating any safety preconditions.
The type Func is available in init and call.
This is effectively our version of an ifunc without linker support. Note that init may be
called more than once until one completes.