What's the right way to make a stack (or other dynamically resizable vector-like thing) in Rust?

允我心安 提交于 2019-12-12 12:25:01

问题


Google turns up many links on old methods that have now been removed from the language, but I can't find a reference on what to do for Rust 0.6.

I've just implemented a linked list, which I could easily repurpose into a stack, but I'd rather use some well-tested, robust, existing data structure from the standard library.


回答1:


I would try, in order :

  • a deque
  • a list or a dlist
  • a vec
  • a mutable owned vector

You can learn more about the containers on the wiki.



来源:https://stackoverflow.com/questions/15886661/whats-the-right-way-to-make-a-stack-or-other-dynamically-resizable-vector-like

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!