In C e C++ è possibile ottenere il nome della funzione attualmente in esecuzione tramite la macro __func__
con C99 & C++ 11 e ___FUNCTION___
per MSVC.Equivalente di __func__ o __FUNCTION__ in Rust?
Esiste un equivalente di questo in Rust?
Esempio di __func__
in C:
#include "stdio.h"
void funny_hello() {
printf ("Hello from %s\n", __func__);
}
int main() {
funny_hello();
}
uscite Hello from funny_hello
.
Si noti che questa implementazione ha anche il limite che non può essere utilizzata attualmente per costruire valori statici, ad esempio: 'nome statico: & 'static str = function!();' –