Background information: I have a function that calls itself both directly and indirectly with the help of other functions, and wants a cheap way to fail gracefully if the program ends from the call stack. I could handle the calls manually, but I would like to get a more elegant and reliable way to achieve this.
Is it possible to determine the current depth of the call stack using stable Rust?
The only options I could find are:
- After the stack in ASM, but it requires instability and is not portable.
- Using the GNU libc extension (backtrace). However, the backtrace is too wasteful and also not standard.
source
share