I need something like .collect() but which will produce String instead of container of chars, i.e. I need an inverse of chars(). I cannot find anything suitable in the documentation. Of course I can implement such a function myself but I'm sure there must be standard solution to this problem.
I'm using stable Rust.
.collect()is generic in what collection it produces, and it can produce theStringfor you!The trait
FromIteratordetermines which elements you can collect into which kind of collection, and among the implementors you can findStringtwice:Both iterators of
charand of&strcan be collected toString.