官术网_书友最值得收藏!

After use

Whenever the list needs to be disposed of, Rust calls a drop() method that is automatically implemented. However, since this is an automated process, each member is dropped recursively—which works OK until the level of nested next pointers exceeds the stack for executing the drop() method and crashes the program with an unexpected stack overflow message.

As a consequence, it is a good idea for production usage to also implement the Drop trait and dispose of the list elements iteratively. By the way, a stack overflow also happens while using the derived Debug implementation to print a Node—for the same reason.

主站蜘蛛池模板: 江都市| 徐闻县| 古浪县| 策勒县| 陇南市| 巴彦县| 体育| 甘孜县| 遂宁市| 句容市| 新泰市| 雷州市| 惠水县| 甘洛县| 武胜县| 石狮市| 龙山县| 清新县| 淄博市| 平阴县| 德惠市| 承德市| 大田县| 车致| 谢通门县| 商南县| 遵化市| 宕昌县| 汤阴县| 伊吾县| 奇台县| 新丰县| 阿克| 巴中市| 石河子市| 博白县| 曲麻莱县| 荆州市| 张家川| 漳浦县| 阳新县|