Background information: I have a function that calls itself both directly and indirectly through other functions, and would like a cheap way to fail gracefully should the program run out of call stack. I could count calls manually, but I would like a more elegant and robust way of achieving this.
Is it possible to determine current call stack depth using stable Rust?
The only options I could find are:
- Following the stack in ASM, but it requires unstable and is not portable.
- Using a GNU libc extension (backtrace). However, backtrace is too wasteful and also not standard.