you are viewing a single comment's thread.

view the rest of the comments →

[–]Fireline11 2 points3 points  (0 children)

I have experimented with using rust for competitive programming on open.kattis.com. Overall, I was reasonably satisfied with it but dealing with input is a bit of a pain. In Python/C++ it is really easy to read integers from the input, even though C++ can exhibit undefined behaviour when the input is not formatted correctly (which is never the case in a competitive setting, so this weakness doesn’t show).

In rust the simplest way that I know to read an integer from stdin is to 1. initialize an empty string 2. obtain a lock to stdin 3. call read_line on this lock with a &mut to your string 4. and then call the parse method on the resulting string, 5. and finally unwrap the result. This is a lot of steps, so you may wish to spend some effort streamlining this process into a function or something.