[英]Does Rust expose call stack depth?
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? 是否可以使用稳定的Rust确定当前的调用堆栈深度?
The only options I could find are: 我能找到的唯一选择是:
The stacker crate seems to provide the functionality you seek: 堆垛板箱似乎提供您所寻求的功能:
The library supports the Linux, Windows and macOS targets. 该库支持Linux,Windows和macOS目标。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.