Working with files, navigation, stl containers


#1

Dear Pros.
Since there is no much information for Rust in the net, i have to ask you about things that i cant find the answers on in the net, besides it turned out that i have been smoking Rust using out of date data and now have to start from the beginning. It is ok though, because i like it.
I would like to know:

  1. if there is analog of (C++ fstream) in Rust and how to work with files .txt and binary ones.
  2. The syntax of creating containers ( vector, map<int,strring> for example).
    3 If Rust has any ability to navigate you through the file system (<direct.h>) and such methods as _find_first(), _find_next() as are in C++ ??

#2

Did you find https://www.rust-lang.org/en-US/documentation.html? The Rust book in particular is a very good resource to get started. Rust-learning (also linked there) contains comparisons to C++, which might suit you.


#3

I am working through it at the moment but there is not enough information. If you please send me a couple of examples it would be greate.


#4

To answer your immediate questions:

  1. Rust’s equivalent of fstream is File
  2. For containers like vector and hash map you can see their documentation here and here. In general in Rust you should be able to find the equivalent of all containers in C++ STL.
  3. Ability to walk the directory hierarchy is not part of Rust’s standard libray but you can use a crate (which is nothing but a library) such as walkdir

All these pages should contain examples.


#5

I usually fall back to these ones when I have time to mess with rust…